36 lines
1.0 KiB
Go
36 lines
1.0 KiB
Go
package resources
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/hashicorp/terraform-plugin-framework/types"
|
|
)
|
|
|
|
func TestEnvironmentToUnstructuredAndBack(t *testing.T) {
|
|
input := environmentResourceModel{
|
|
Name: types.StringValue("env-a"),
|
|
Image: types.StringValue("ghcr.io/fission/python-env"),
|
|
Version: types.Int64Value(3),
|
|
PoolSize: types.Int64Value(5),
|
|
}
|
|
|
|
obj := environmentToUnstructured(input, "default")
|
|
state := unstructuredToEnvironmentModel(obj, input)
|
|
|
|
if state.Name.ValueString() != "env-a" {
|
|
t.Fatalf("unexpected name: %q", state.Name.ValueString())
|
|
}
|
|
if state.Namespace.ValueString() != "default" {
|
|
t.Fatalf("unexpected namespace: %q", state.Namespace.ValueString())
|
|
}
|
|
if state.Image.ValueString() != "ghcr.io/fission/python-env" {
|
|
t.Fatalf("unexpected image: %q", state.Image.ValueString())
|
|
}
|
|
if state.Version.ValueInt64() != 3 {
|
|
t.Fatalf("unexpected version: %d", state.Version.ValueInt64())
|
|
}
|
|
if state.PoolSize.ValueInt64() != 5 {
|
|
t.Fatalf("unexpected poolsize: %d", state.PoolSize.ValueInt64())
|
|
}
|
|
}
|