Skip to content

Commit

Permalink
chore: align test naming
Browse files Browse the repository at this point in the history
  • Loading branch information
agparadiso committed Jan 9, 2025
1 parent fed0e8b commit 6de231a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pkg/workflows/wasm/host/module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -553,22 +553,22 @@ func Test_read(t *testing.T) {
}

func Test_write(t *testing.T) {
t.Run("OK-successfully_write_to_slice", func(t *testing.T) {
t.Run("successfully write to slice", func(t *testing.T) {
giveSrc := []byte("hello, world")
memory := make([]byte, 12)
n := write(memory, giveSrc, 0, int32(len(giveSrc)))
assert.Equal(t, n, int64(len(giveSrc)))
assert.Equal(t, []byte("hello, world"), memory[:len(giveSrc)])
})

t.Run("NOK-cannot_write_to_slice_because_memory_too_small", func(t *testing.T) {
t.Run("cannot write to slice because memory too small", func(t *testing.T) {
giveSrc := []byte("hello, world")
memory := make([]byte, len(giveSrc)-1)
n := write(memory, giveSrc, 0, int32(len(giveSrc)))
assert.Equal(t, int64(-1), n)
})

t.Run("NOK-fails_to_write_to_invalid_access", func(t *testing.T) {
t.Run("fails to write to invalid access", func(t *testing.T) {
giveSrc := []byte("hello, world")
memory := make([]byte, len(giveSrc))
n := write(memory, giveSrc, 0, -1)
Expand All @@ -578,14 +578,14 @@ func Test_write(t *testing.T) {
assert.Equal(t, int64(-1), n)
})

t.Run("NOK-truncated_write_due_to_size_being_smaller_than_len", func(t *testing.T) {
t.Run("truncated write due to size being smaller than len", func(t *testing.T) {
giveSrc := []byte("hello, world")
memory := make([]byte, 12)
n := write(memory, giveSrc, 0, int32(len(giveSrc)-2))
assert.Equal(t, int64(-1), n)
})

t.Run("NOK-unwanted_data_when_size_exceeds_written_data", func(t *testing.T) {
t.Run("unwanted data when size exceeds written data", func(t *testing.T) {
giveSrc := []byte("hello, world")
memory := make([]byte, 20)
n := write(memory, giveSrc, 0, 20)
Expand Down

0 comments on commit 6de231a

Please sign in to comment.