-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapi_scripting_test.go
42 lines (35 loc) · 1.04 KB
/
api_scripting_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
package squeeze_go_client
import (
"github.com/dexpro-solutions-gmbh/squeeze-go-client/internal"
"github.com/stretchr/testify/assert"
"testing"
)
func TestScriptingApi_GetScripts(t *testing.T) {
c := NewClient(internal.GetEnvVal("SQZ_BASE_PATH"))
c.ApiKey = internal.GetEnvApiKey(t)
scripts, e := c.ScriptingApi.GetScripts()
assert.Nil(t, e)
assert.NotNil(t, scripts)
assert.NotEmpty(t, scripts)
}
func TestScriptingApi_ExecuteScript(t *testing.T) {
c := NewClient(internal.GetEnvVal("SQZ_BASE_PATH"))
c.ApiKey = internal.GetEnvApiKey(t)
scripts, e := c.ScriptingApi.GetScripts()
assert.Nil(t, e)
assert.NotNil(t, scripts)
assert.NotEmpty(t, scripts)
// Get unlock script, that one is safe to test in CI / etc.
var unlockScript *ScriptDto
for _, script := range scripts {
if script.Name == "(Internal) unlock-documents" {
unlockScript = script
break
}
}
if unlockScript == nil {
t.Error("Could not find unlock script to test execution with")
}
e = c.ScriptingApi.ExecuteScript(unlockScript.Id, false)
assert.Nil(t, e)
}