Skip to content

Commit

Permalink
add unit test for NodeList
Browse files Browse the repository at this point in the history
  • Loading branch information
djelusic committed Mar 10, 2022
1 parent c16e9cf commit 45df298
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions domain/workspace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package domain
import (
"strings"
"testing"
"time"

"github.com/mantil-io/mantil/kit/token"
"github.com/stretchr/testify/require"
)

Expand Down Expand Up @@ -189,3 +191,27 @@ func TestEventRemoveAwsCredentials(t *testing.T) {
expected = "mantil aws install --aws-access-key-id *** --aws-secret-access-key *** --aws-region us-east-1"
require.Equal(t, expected, strings.Join(args, " "))
}

func TestNodeList(t *testing.T) {
w := Workspace{
Nodes: []*Node{
{
Name: "node1",
},
},
}
n2 := &Node{
Name: "node2",
}
_, privateKey, _ := token.KeyPair()
token, _ := token.JWT(privateKey, AccessTokenClaims{
Node: n2,
}, time.Hour)
w.AddNodeToken(token)

nodes, err := w.NodeList()
require.NoError(t, err)
require.Len(t, nodes, 2)
require.Equal(t, "node1", nodes[0].Name)
require.Equal(t, "node2", nodes[1].Name)
}

0 comments on commit 45df298

Please sign in to comment.