MCPcopy Create free account
hub / github.com/devfile/api / setMetaDataValues

Method setMetaDataValues

test/v200/utils/common/metadata_test_utils.go:62–92  ·  view source on GitHub ↗

setMetadataValues randomly adds/modifies metadata object properties. Since these are optional properties, the test is set up so they are twice as likely to appear in the generated files to ensure sufficient coverage.

(metadata *header.DevfileMetadata)

Source from the content-addressed store, hash-verified

60// setMetadataValues randomly adds/modifies metadata object properties. Since these are optional properties, the test is
61// set up so they are twice as likely to appear in the generated files to ensure sufficient coverage.
62func (devfile *TestDevfile) setMetaDataValues(metadata *header.DevfileMetadata) {
63 setProperty("Description", &metadata.Description)
64 setProperty("DisplayName", &metadata.DisplayName)
65 setProperty("GlobalMemoryLimit", &metadata.GlobalMemoryLimit)
66 setProperty("Icon", &metadata.Icon)
67 setProperty("Name", &metadata.Name)
68
69 if GetRandomDecision(2, 1) {
70
71 numTags := GetRandomNumber(1, 5)
72 LogInfoMessage(fmt.Sprintf(" ....... add %d tag(s) to tags ", numTags))
73 for i := 0; i < numTags; i++ {
74 metadata.Tags = append(metadata.Tags, GetRandomString(8, false))
75 }
76
77 }
78
79 if GetRandomDecision(2, 1) {
80 //generate a valid version string based on the regex that's in the spec. Limit each segment to max 3 characters. e.g. 339.957.11-t.9+-.nkJ will be generated
81 version, err := reggen.Generate("^([0-9]+)\\.([0-9]+)\\.([0-9]+)(\\-[0-9a-z-]+(\\.[0-9a-z-]+)*)?(\\+[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?$", 3)
82 if err != nil {
83 LogErrorMessage("Failed to generate random version, schema version will be used")
84 version = devfile.SchemaDevFile.SchemaVersion
85 }
86
87 metadata.Version = version
88 LogInfoMessage(fmt.Sprintf(" ....... Version %s", metadata.Version))
89 }
90
91 devfile.MetaDataUpdated(metadata)
92}

Callers 1

AddMetaDataMethod · 0.95

Calls 8

MetaDataUpdatedMethod · 0.95
setPropertyFunction · 0.85
GetRandomDecisionFunction · 0.85
GetRandomNumberFunction · 0.85
LogInfoMessageFunction · 0.85
GetRandomStringFunction · 0.85
LogErrorMessageFunction · 0.85
GenerateMethod · 0.45

Tested by

no test coverage detected