-
Notifications
You must be signed in to change notification settings - Fork 20
/
generate_test.go
56 lines (48 loc) · 1.7 KB
/
generate_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package overflow
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
/*
Tests must be in the same folder as flow.json with contracts and transactions/scripts in subdirectories in order for the path resolver to work correctly
*/
func TestGenerate(t *testing.T) {
o, err := OverflowTesting()
require.NoError(t, err)
t.Run("script", func(t *testing.T) {
stub, err := o.GenerateStub("emulator", "scripts/test.cdc", false)
assert.NoError(t, err)
assert.Equal(t, " o.Script(\"test\",\n WithArg(\"account\", <>), //Address\n )", stub)
})
t.Run("script with no arg", func(t *testing.T) {
stub, err := o.GenerateStub("emulator", "scripts/type.cdc", false)
assert.NoError(t, err)
assert.Equal(t, " o.Script(\"type\")", stub)
})
t.Run("transaction", func(t *testing.T) {
stub, err := o.GenerateStub("emulator", "transactions/arguments.cdc", false)
assert.NoError(t, err)
assert.Equal(t, " o.Tx(\"arguments\",\n WithSigner(\"<>\"),\n WithArg(\"test\", <>), //String\n )", stub)
})
t.Run("transaction with no args", func(t *testing.T) {
stub, err := o.GenerateStub("emulator", "transactions/create_nft_collection.cdc", false)
assert.NoError(t, err)
assert.Equal(t, " o.Tx(\"create_nft_collection\",\n WithSigner(\"<>\"),\n )", stub)
})
t.Run("transaction standalone", func(t *testing.T) {
stub, err := o.GenerateStub("emulator", "transactions/arguments.cdc", true)
assert.NoError(t, err)
assert.Equal(t, `package main
import (
. "github.com/bjartek/overflow/v2"
)
func main() {
o := Overflow(WithNetwork("emulator"), WithPrintResults())
o.Tx("arguments",
WithSigner("<>"),
WithArg("test", <>), //String
)
}`, stub)
})
}