Skip to content

Commit a3ecbda

Browse files
committed
Add unit test
1 parent 7c07c26 commit a3ecbda

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

lib/runtime/wasmer/config_test.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Copyright 2022 ChainSafe Systems (ON)
2+
// SPDX-License-Identifier: LGPL-3.0-only
3+
4+
package wasmer
5+
6+
import (
7+
"testing"
8+
9+
"github.com/ChainSafe/gossamer/lib/runtime"
10+
"github.com/stretchr/testify/assert"
11+
"github.com/stretchr/testify/require"
12+
)
13+
14+
func Test_Config_SetTestVersion(t *testing.T) {
15+
t.Run("panics with nil *testing.T", func(t *testing.T) {
16+
var c Config
17+
assert.PanicsWithValue(t,
18+
"*testing.T argument cannot be nil. Please don't use this function outside of Go tests.",
19+
func() {
20+
c.SetTestVersion(nil, runtime.Version{})
21+
})
22+
})
23+
24+
t.Run("set test version", func(t *testing.T) {
25+
var c Config
26+
testVersion := runtime.Version{
27+
StateVersion: 1,
28+
}
29+
30+
c.SetTestVersion(t, testVersion)
31+
32+
require.NotNil(t, c.testVersion)
33+
assert.Equal(t, testVersion, *c.testVersion)
34+
})
35+
}

0 commit comments

Comments
 (0)