1
0
mirror of https://github.com/juanfont/headscale.git synced 2025-09-11 17:53:10 +02:00

Corrected unit tests

This commit is contained in:
hopleus 2024-10-17 14:20:13 +03:00
parent 64e8cf9001
commit ed1042076a
3 changed files with 8 additions and 6 deletions

View File

@ -202,6 +202,7 @@ func (s *Suite) TestListPeersWithoutNonAuthorized(c *check.C) {
} }
node := types.Node{ node := types.Node{
// nolint:G115
ID: types.NodeID(uint64(index)), ID: types.NodeID(uint64(index)),
MachineKey: machineKey.Public(), MachineKey: machineKey.Public(),
NodeKey: nodeKey.Public(), NodeKey: nodeKey.Public(),

View File

@ -13,7 +13,7 @@ import (
"strings" "strings"
"testing" "testing"
"github.com/juanfont/headscale/gen/go/headscale/v1" v1 "github.com/juanfont/headscale/gen/go/headscale/v1"
"github.com/juanfont/headscale/hscontrol/types" "github.com/juanfont/headscale/hscontrol/types"
"github.com/juanfont/headscale/integration/hsic" "github.com/juanfont/headscale/integration/hsic"
"github.com/samber/lo" "github.com/samber/lo"

View File

@ -4,6 +4,7 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"sort" "sort"
"strconv"
"strings" "strings"
"testing" "testing"
"time" "time"
@ -1245,7 +1246,7 @@ func TestNodeApproveCommand(t *testing.T) {
"json", "json",
}, },
) )
assert.NoError(t, err) assertNoErr(t, err)
var node v1.Node var node v1.Node
err = executeAndUnmarshal( err = executeAndUnmarshal(
@ -1263,7 +1264,7 @@ func TestNodeApproveCommand(t *testing.T) {
}, },
&node, &node,
) )
assert.NoError(t, err) assertNoErr(t, err)
nodes[index] = &node nodes[index] = &node
} }
@ -1282,7 +1283,7 @@ func TestNodeApproveCommand(t *testing.T) {
}, },
&listAll, &listAll,
) )
assert.NoError(t, err) assertNoErr(t, err)
assert.Len(t, listAll, 5) assert.Len(t, listAll, 5)
@ -1292,14 +1293,14 @@ func TestNodeApproveCommand(t *testing.T) {
assert.False(t, listAll[3].GetApproved()) assert.False(t, listAll[3].GetApproved())
assert.False(t, listAll[4].GetApproved()) assert.False(t, listAll[4].GetApproved())
for idx := 0; idx < 3; idx++ { for idx := range [3]int{} {
_, err := headscale.Execute( _, err := headscale.Execute(
[]string{ []string{
"headscale", "headscale",
"nodes", "nodes",
"approve", "approve",
"--identifier", "--identifier",
fmt.Sprintf("%d", listAll[idx].GetId()), strconv.FormatUint(listAll[idx].GetId(), 10),
}, },
) )
assert.NoError(t, err) assert.NoError(t, err)