Skip to content

Commit

Permalink
Fix some linting in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
webmaster128 committed Jul 16, 2023
1 parent 4f5bdab commit d0d79cc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion internal/api/version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ import (
func TestLibwasmvmVersion(t *testing.T) {
version, err := LibwasmvmVersion()
require.NoError(t, err)
require.Regexp(t, regexp.MustCompile("^([0-9]+)\\.([0-9]+)\\.([0-9]+)(-[a-z0-9.]+)?$"), version)
require.Regexp(t, regexp.MustCompile(`^([0-9]+)\.([0-9]+)\.([0-9]+)(-[a-z0-9.]+)?$`), version)
}
10 changes: 5 additions & 5 deletions lib_no_cgo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,24 @@ import (

func TestCreateChecksum(t *testing.T) {
// nil
checksum, err := CreateChecksum(nil)
_, err := CreateChecksum(nil)
require.ErrorContains(t, err, "nil or empty")

// empty
checksum, err = CreateChecksum([]byte{})
_, err = CreateChecksum([]byte{})
require.ErrorContains(t, err, "nil or empty")

// short
checksum, err = CreateChecksum([]byte("\x00\x61\x73"))
_, err = CreateChecksum([]byte("\x00\x61\x73"))
require.ErrorContains(t, err, " shorter than 4 bytes")

// Wasm blob returns correct hash
// echo "(module)" > my.wat && wat2wasm my.wat && hexdump -C my.wasm && sha256sum my.wasm
checksum, err = CreateChecksum([]byte("\x00\x61\x73\x6d\x01\x00\x00\x00"))
checksum, err := CreateChecksum([]byte("\x00\x61\x73\x6d\x01\x00\x00\x00"))
require.NoError(t, err)
require.Equal(t, types.ForceNewChecksum("93a44bbb96c751218e4c00d479e4c14358122a389acca16205b1e4d0dc5f9476"), checksum)

// Text file fails
checksum, err = CreateChecksum([]byte("Hello world"))
_, err = CreateChecksum([]byte("Hello world"))
require.ErrorContains(t, err, "do not not start with Wasm magic number")
}

0 comments on commit d0d79cc

Please sign in to comment.