mirror of
https://github.com/FairwindsOps/polaris.git
synced 2026-05-21 08:33:55 +00:00
47 lines
1.2 KiB
Go
47 lines
1.2 KiB
Go
package validator
|
|
|
|
import (
|
|
"testing"
|
|
|
|
conf "github.com/reactiveops/fairwinds/pkg/config"
|
|
"github.com/reactiveops/fairwinds/test"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestValidatePod(t *testing.T) {
|
|
r := conf.ResourceRequire{Require: true}
|
|
c := conf.Configuration{
|
|
HostNetworking: conf.HostNetworking{
|
|
HostAlias: r,
|
|
HostIPC: r,
|
|
HostNetwork: r,
|
|
HostPID: r,
|
|
HostPort: r,
|
|
},
|
|
}
|
|
|
|
k8s := test.SetupTestAPI()
|
|
k8s = test.SetupAddDeploys(k8s, "test")
|
|
pod := test.MockPod()
|
|
|
|
expectedSum := ResultSummary{
|
|
Successes: uint(9),
|
|
Warnings: uint(0),
|
|
Failures: uint(0),
|
|
}
|
|
|
|
expectedMssgs := []ResultMessage{
|
|
ResultMessage{Message: "Host alias is not configured", Type: "success"},
|
|
ResultMessage{Message: "Host IPC is not configured", Type: "success"},
|
|
ResultMessage{Message: "Host PID is not configured", Type: "success"},
|
|
ResultMessage{Message: "Host network is not configured", Type: "success"},
|
|
}
|
|
|
|
actualRR := ValidatePod(c, &pod.Spec)
|
|
|
|
assert.Equal(t, actualRR.Type, "Pod", "should be equal")
|
|
assert.Equal(t, len(actualRR.ContainerResults), 0, "should be equal")
|
|
assert.EqualValues(t, actualRR.Summary, &expectedSum)
|
|
assert.EqualValues(t, actualRR.PodResults[0].Messages, expectedMssgs)
|
|
}
|