mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-25 09:50:31 +00:00
3b0263442a
Co-authored-by: laszlocph <laszlo@laszlo.cloud> Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: Rynoxx <rynoxx@grid-servers.net>
62 lines
1.2 KiB
Go
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))
|
|
}
|