Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bcmmbaga committed Jan 17, 2024
1 parent 1d6fe40 commit af37b46
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion management/server/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ func (a *Account) validatePostureChecksOnPeer(sourcePostureChecksID []string, pe
isValid, err := check.Check(*peer)
if !isValid {
if err != nil {
log.Debugf("an error occured check %s: on peer: %s :%s", check.Name(), peer.ID, err.Error())
log.Debugf("an error occurred check %s: on peer: %s :%s", check.Name(), peer.ID, err.Error())
}
return false
}
Expand Down
14 changes: 11 additions & 3 deletions management/server/posture/version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ func TestNBVersionCheck_Check(t *testing.T) {
input peer.Peer
check NBVersionCheck
wantErr bool
isValid bool
}{
{
name: "Valid Peer NB version",
Expand All @@ -26,6 +27,7 @@ func TestNBVersionCheck_Check(t *testing.T) {
MinVersion: "1.0.0",
},
wantErr: false,
isValid: true,
},
{
name: "Valid Peer NB version With No Patch Version 1",
Expand All @@ -38,6 +40,7 @@ func TestNBVersionCheck_Check(t *testing.T) {
MinVersion: "2.0",
},
wantErr: false,
isValid: true,
},
{
name: "Valid Peer NB version With No Patch Version 2",
Expand All @@ -50,6 +53,7 @@ func TestNBVersionCheck_Check(t *testing.T) {
MinVersion: "2.0",
},
wantErr: false,
isValid: true,
},
{
name: "Older Peer NB version",
Expand All @@ -61,7 +65,8 @@ func TestNBVersionCheck_Check(t *testing.T) {
check: NBVersionCheck{
MinVersion: "1.0.0",
},
wantErr: true,
wantErr: false,
isValid: false,
},
{
name: "Older Peer NB version With Patch Version",
Expand All @@ -73,7 +78,8 @@ func TestNBVersionCheck_Check(t *testing.T) {
check: NBVersionCheck{
MinVersion: "0.2",
},
wantErr: true,
wantErr: false,
isValid: false,
},
{
name: "Invalid Peer NB version",
Expand All @@ -86,17 +92,19 @@ func TestNBVersionCheck_Check(t *testing.T) {
MinVersion: "1.0.0",
},
wantErr: true,
isValid: false,
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
err := tt.check.Check(tt.input)
isValid, err := tt.check.Check(tt.input)
if tt.wantErr {
assert.Error(t, err)
} else {
assert.NoError(t, err)
}
assert.Equal(t, tt.isValid, isValid)
})
}
}

0 comments on commit af37b46

Please sign in to comment.