-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathsetup_test.go
126 lines (105 loc) · 3.39 KB
/
setup_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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
package overflow
import (
"testing"
"github.com/onflow/flowkit/v2/output"
"github.com/stretchr/testify/assert"
)
func TestOverflowv3(t *testing.T) {
t.Run("WithNetworkEmbedded", func(t *testing.T) {
b := Apply(WithNetwork("embedded"))
assert.Equal(t, "emulator", b.Network)
assert.True(t, b.DeployContracts)
assert.True(t, b.InitializeAccounts)
assert.True(t, b.InMemory)
assert.Equal(t, output.NoneLog, b.LogLevel)
})
t.Run("WithNetworkTesting", func(t *testing.T) {
b := Apply(WithNetwork("testing"))
assert.Equal(t, "emulator", b.Network)
assert.True(t, b.DeployContracts)
assert.True(t, b.InitializeAccounts)
assert.True(t, b.InMemory)
assert.Equal(t, output.NoneLog, b.LogLevel)
})
t.Run("WithNetworkEmulator", func(t *testing.T) {
b := Apply(WithNetwork("emulator"))
assert.Equal(t, "emulator", b.Network)
assert.True(t, b.DeployContracts)
assert.True(t, b.InitializeAccounts)
assert.False(t, b.InMemory)
})
t.Run("WithNetworkTestnet", func(t *testing.T) {
b := Apply(WithNetwork("testnet"))
assert.Equal(t, "testnet", b.Network)
assert.False(t, b.DeployContracts)
assert.False(t, b.InitializeAccounts)
assert.False(t, b.InMemory)
})
t.Run("WithNetworkMainnet", func(t *testing.T) {
b := Apply(WithNetwork("mainnet"))
assert.Equal(t, "mainnet", b.Network)
assert.False(t, b.DeployContracts)
assert.False(t, b.InitializeAccounts)
assert.False(t, b.InMemory)
})
t.Run("WithInMemory", func(t *testing.T) {
b := Apply()
assert.True(t, b.InMemory)
assert.True(t, b.InitializeAccounts)
assert.True(t, b.DeployContracts)
assert.Equal(t, "emulator", b.Network)
})
t.Run("WithExistingEmulator", func(t *testing.T) {
b := Apply(WithExistingEmulator())
assert.False(t, b.InitializeAccounts)
assert.False(t, b.DeployContracts)
})
t.Run("DoNotPrependNetworkToAccountNames", func(t *testing.T) {
b := Apply(WithNoPrefixToAccountNames())
assert.False(t, b.PrependNetworkName)
})
t.Run("WithServiceAccountSuffix", func(t *testing.T) {
b := Apply(WithServiceAccountSuffix("foo"))
assert.Equal(t, "foo", b.ServiceSuffix)
})
t.Run("WithBasePath", func(t *testing.T) {
b := Apply(WithBasePath("../"))
assert.Equal(t, "../", b.Path)
})
t.Run("WithNoLog", func(t *testing.T) {
b := Apply(WithLogNone())
assert.Equal(t, output.NoneLog, b.LogLevel)
})
t.Run("WithGas", func(t *testing.T) {
b := Apply(WithGas(42))
assert.Equal(t, 42, b.GasLimit)
})
t.Run("WithFlowConfig", func(t *testing.T) {
b := Apply(WithFlowConfig("foo.json", "bar.json"))
assert.Equal(t, []string{"foo.json", "bar.json"}, b.ConfigFiles)
})
t.Run("WithScriptFolderName", func(t *testing.T) {
b := Apply(WithScriptFolderName("script"))
assert.Equal(t, "script", b.ScriptFolderName)
})
t.Run("WithGlobalPrintOptions", func(t *testing.T) {
b := Apply(WithGlobalPrintOptions(WithoutId()))
assert.Equal(t, 1, len(*b.PrintOptions))
})
t.Run("WithPrintResults", func(t *testing.T) {
b := Apply(WithPrintResults(WithoutId()))
assert.Equal(t, 1, len(*b.PrintOptions))
})
t.Run("WithTransactionFolderName", func(t *testing.T) {
b := Apply(WithTransactionFolderName("tx"))
assert.Equal(t, "tx", b.TransactionFolderName)
})
t.Run("Overflow panics", func(t *testing.T) {
assert.Panics(t, func() {
Overflow(WithFlowConfig("nonexistant.json"))
})
})
}
func Apply(opt ...OverflowOption) *OverflowBuilder {
return defaultOverflowBuilder.applyOptions(opt)
}