MCPcopy Index your code
hub / github.com/bitfield/script / TestSHA256Sum_OutputsCorrectHash

Function TestSHA256Sum_OutputsCorrectHash

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

Source from the content-addressed store, hash-verified

1568}
1569
1570func TestSHA256Sum_OutputsCorrectHash(t *testing.T) {
1571 t.Parallel()
1572 tcs := []struct {
1573 name, input, want string
1574 }{
1575 {
1576 name: "for no data",
1577 input: "",
1578 want: "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
1579 },
1580 {
1581 name: "for short string",
1582 input: "hello, world",
1583 want: "09ca7e4eaa6e8ae9c7d261167129184883644d07dfba7cbfbc4c8a2e08360d5b",
1584 },
1585 {
1586 name: "for string containing newline",
1587 input: "The tao that can be told\nis not the eternal Tao",
1588 want: "788542cb92d37f67e187992bdb402fdfb68228a1802947f74c6576e04790a688",
1589 },
1590 }
1591
1592 for _, tc := range tcs {
1593 t.Run(tc.name, func(t *testing.T) {
1594 got, err := script.Echo(tc.input).SHA256Sum()
1595 if err != nil {
1596 t.Fatal(err)
1597 }
1598 if got != tc.want {
1599 t.Errorf("want %q, got %q", tc.want, got)
1600 }
1601 })
1602 }
1603}
1604
1605func TestSHA256Sum_ReturnsErrorGivenReadErrorOnPipe(t *testing.T) {
1606 t.Parallel()

Callers

nothing calls this directly

Calls 2

EchoFunction · 0.92
SHA256SumMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…