mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-03 23:26:29 +00:00
63 lines
1.2 KiB
Go
63 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))
|
||
|
}
|