Skip to content

Commit

Permalink
added one integration test for initializing three clients
Browse files Browse the repository at this point in the history
  • Loading branch information
sam-1pass committed Jan 19, 2024
1 parent e0f6fc6 commit 87bd91b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 29 deletions.
28 changes: 0 additions & 28 deletions core_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,6 @@ func TestNewClientId(t *testing.T) {
}
}

func TestInitClientIncrement(t *testing.T) {
ctx := context.TODO()
core, _ := NewExtismCore(ctx)
config := ClientConfig{} //TODO: make valid config
value1, _ := Core.InitClient(core, config)
value2, _ := Core.InitClient(core, config)
value3, _ := Core.InitClient(core, config)
if *value1 != 0 || *value2 != 1 || *value3 != 2 {
t.Fatalf("client id does not increment")
}
}

func TestInvalidClientConfig(t *testing.T) {
ctx := context.TODO()
core, _ := NewExtismCore(ctx)
Expand All @@ -89,22 +77,6 @@ func TestInvalidClientConfig(t *testing.T) {
require.Error(t, err)
}

func TestInvokeReturnsSecret(t *testing.T) {

clientId := 0
methodName := ""
params := ""

ctx := context.TODO()
core, _ := NewExtismCore(ctx)
invocation := Invocation{uint64(clientId), methodName, params}
invoke, err := Core.Invoke(core, invocation)
require.NoError(t, err)

//TODO: setup on valid test secret reference
*invoke = "" // just here to remove error temporarily
}

func TestInvalidInvoke(t *testing.T) {

valid_clientId := 0
Expand Down
28 changes: 27 additions & 1 deletion integration_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package onepassword

import (
"assert"

Check failure on line 4 in integration_test.go

View workflow job for this annotation

GitHub Actions / validate

package assert is not in std (/opt/hostedtoolcache/go/1.21.5/x64/src/assert)

Check failure on line 4 in integration_test.go

View workflow job for this annotation

GitHub Actions / validate

package assert is not in std (/opt/hostedtoolcache/go/1.21.5/x64/src/assert)
"context"
"github.com/stretchr/testify/assert"
"os"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

// These tests were designed for CI/CD. If you want to run them locally you must make sure the following dependencies are in place:
Expand Down Expand Up @@ -34,3 +37,26 @@ func TestSecretRetrievalFromTestAccount(t *testing.T) {

assert.Equal(t, "test_password", *secret)
}

func TestInitClientIncrement(t *testing.T) {

token := os.Getenv("OP_SERVICE_ACCOUNT_TOKEN")

ctx := context.TODO()
core, _ := NewExtismCore(ctx)
config := NewDefaultConfig()
config.SAToken = token
config.IntegrationName = "name"
config.IntegrationVersion = "version"

value1, err1 := Core.InitClient(core, config)
require.NoError(t, err1)
value2, err2 := Core.InitClient(core, config)
require.NoError(t, err2)
value3, err3 := Core.InitClient(core, config)
require.NoError(t, err3)

assert.Equal(t, 0, value1)
assert.Equal(t, 1, value2)
assert.Equal(t, 2, value3)
}

0 comments on commit 87bd91b

Please sign in to comment.