MCPcopy Create free account
hub / github.com/OpenAtomFoundation/SmartIDE / TestImage

Function TestImage

cli/pkg/docker/compose/image_test.go:27–67  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

25)
26
27func TestImage(t *testing.T) {
28 tests := []struct {
29 item string
30 wantName string
31 wantTag string
32 wantErr bool
33 }{
34 {"testimage:mainline", "testimage", "mainline", false},
35 {"testimage", "testimage", "", false},
36 {"testimage:mainline:tag", "", "", true},
37 }
38 for i, tt := range tests {
39 t.Run(fmt.Sprintf("%d", i), func(t *testing.T) {
40 // MarshalYaml
41 if !tt.wantErr {
42 item := Image{Name: tt.wantName, Tag: tt.wantTag}
43 content := MarshalYaml(item)
44 content = strings.TrimRight(content, "\n")
45 if content != tt.item {
46 t.Errorf("Image.MarshalYAML() content = %v, wantContent %v", content, tt.item)
47 return
48 }
49 }
50 // UnmarshalYaml
51 var item Image
52 err := UnmarshalYaml(tt.item, &item)
53 if (err != nil) != tt.wantErr {
54 t.Errorf("Image.UnarshalYAML() error = %v, wantErr %v", err, tt.wantErr)
55 return
56 }
57 if item.Name != tt.wantName {
58 t.Errorf("Image.UnarshalYAML() name = %v, wantName %v", item.Name, tt.wantName)
59 return
60 }
61 if item.Tag != tt.wantTag {
62 t.Errorf("Image.UnarshalYAML() tag = %v, wantTag %v", item.Tag, tt.wantTag)
63 return
64 }
65 })
66 }
67}

Callers

nothing calls this directly

Calls 3

MarshalYamlFunction · 0.85
UnmarshalYamlFunction · 0.85
RunMethod · 0.80

Tested by

no test coverage detected