MCPcopy
hub / github.com/hashicorp/go-getter / TestFileChecksum_String

Function TestFileChecksum_String

checksum_test.go:66–99  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

64}
65
66func TestFileChecksum_String(t *testing.T) {
67 type fields struct {
68 checksum string
69 }
70 wd, err := os.Getwd()
71 if err != nil {
72 t.Fatalf(err.Error())
73 }
74 tests := []struct {
75 fields fields
76 want string
77 }{
78 {fields{"090992ba9fd140077b0661cb75f7ce13"}, "md5:090992ba9fd140077b0661cb75f7ce13"},
79 {fields{"ebfb681885ddf1234c18094a45bbeafd91467911"}, "sha1:ebfb681885ddf1234c18094a45bbeafd91467911"},
80 {fields{"sha256:ed363350696a726b7932db864dda019bd2017365c9e299627830f06954643f93"}, "sha256:ed363350696a726b7932db864dda019bd2017365c9e299627830f06954643f93"},
81 {fields{"file:" + filepath.Join(wd, fixtureDir, "checksum-file", "sha1.sum")}, "sha1:e2c7dc83ac8aa7f181314387f6dfb132cd117e3a"},
82 }
83
84 for i, tt := range tests {
85 t.Run(strconv.Itoa(i), func(t *testing.T) {
86 req := &Request{
87 Src: "http://example.dev?checksum=" + tt.fields.checksum,
88 }
89 c, err := DefaultClient.GetChecksum(context.TODO(), req)
90 if err != nil {
91 t.Fatalf("GetChecksum: %v", err)
92 }
93
94 if got := c.String(); got != tt.want {
95 t.Errorf("FileChecksum.String() = %v, want %v", got, tt.want)
96 }
97 })
98 }
99}

Callers

nothing calls this directly

Calls 3

GetChecksumMethod · 0.80
ErrorMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected