Skip to content

Commit

Permalink
Add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
qdm12 committed Sep 15, 2022
1 parent 95a9f00 commit 871719b
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions lib/runtime/wasmer/config_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright 2022 ChainSafe Systems (ON)
// SPDX-License-Identifier: LGPL-3.0-only

package wasmer

import (
"testing"

"github.com/ChainSafe/gossamer/lib/runtime"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func Test_Config_SetTestVersion(t *testing.T) {
t.Run("panics with nil *testing.T", func(t *testing.T) {
var c Config
assert.PanicsWithValue(t,
"*testing.T argument cannot be nil. Please don't use this function outside of Go tests.",
func() {
c.SetTestVersion(nil, runtime.Version{})
})
})

t.Run("set test version", func(t *testing.T) {
var c Config
testVersion := runtime.Version{
StateVersion: 1,
}

c.SetTestVersion(t, testVersion)

require.NotNil(t, c.testVersion)
assert.Equal(t, testVersion, *c.testVersion)
})
}

0 comments on commit 871719b

Please sign in to comment.