MCPcopy
hub / github.com/bitfield/script / TestSHA256Sums_OutputsCorrectHashForEachSpecifiedFile

Function TestSHA256Sums_OutputsCorrectHashForEachSpecifiedFile

script_test.go:1169–1189  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1167}
1168
1169func TestSHA256Sums_OutputsCorrectHashForEachSpecifiedFile(t *testing.T) {
1170 t.Parallel()
1171 tcs := []struct {
1172 testFileName string
1173 want string
1174 }{
1175 // To get the checksum run: openssl dgst -sha256 <file_name>
1176 {"testdata/hashSum.input.txt", "1870478d23b0b4db37735d917f4f0ff9393dd3e52d8b0efa852ab85536ddad8e\n"},
1177 {"testdata/hello.txt", "b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9\n"},
1178 {"testdata/multiple_files", "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\ne3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\ne3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\n"},
1179 }
1180 for _, tc := range tcs {
1181 got, err := script.ListFiles(tc.testFileName).SHA256Sums().String()
1182 if err != nil {
1183 t.Fatal(err)
1184 }
1185 if got != tc.want {
1186 t.Errorf("%q: want %q, got %q", tc.testFileName, tc.want, got)
1187 }
1188 }
1189}
1190
1191func TestTeeUsesConfiguredStdoutAsDefault(t *testing.T) {
1192 t.Parallel()

Callers

nothing calls this directly

Calls 3

ListFilesFunction · 0.92
StringMethod · 0.80
SHA256SumsMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…