woodpecker/pipeline/backend/kubernetes/volume_test.go
Anbraten 3b0263442a
Adding initial version of Kubernetes backend (#552)
Co-authored-by: laszlocph <laszlo@laszlo.cloud>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Rynoxx <rynoxx@grid-servers.net>
2022-09-05 06:01:14 +02:00

62 lines
1.2 KiB
Go

package kubernetes
import (
"encoding/json"
"testing"
"github.com/stretchr/testify/assert"
)
func TestPersistentVolumeClaim(t *testing.T) {
expectedRwx := `
{
"metadata": {
"name": "someName",
"namespace": "someNamespace",
"creationTimestamp": null
},
"spec": {
"accessModes": [
"ReadWriteMany"
],
"resources": {
"requests": {
"storage": "1Gi"
}
},
"storageClassName": "local-storage"
},
"status": {}
}`
expectedRwo := `
{
"metadata": {
"name": "someName",
"namespace": "someNamespace",
"creationTimestamp": null
},
"spec": {
"accessModes": [
"ReadWriteOnce"
],
"resources": {
"requests": {
"storage": "1Gi"
}
},
"storageClassName": "local-storage"
},
"status": {}
}`
pvc := PersistentVolumeClaim("someNamespace", "someName", "local-storage", "1Gi", true)
j, err := json.Marshal(pvc)
assert.Nil(t, err)
assert.JSONEq(t, expectedRwx, string(j))
pvc = PersistentVolumeClaim("someNamespace", "someName", "local-storage", "1Gi", false)
j, err = json.Marshal(pvc)
assert.Nil(t, err)
assert.JSONEq(t, expectedRwo, string(j))
}