Example #1
0
func TestNewPrimative(t *testing.T) {
	t.Parallel()

	value, err := forge.NewPrimative(true)
	if err != nil {
		t.Error(err)
		return
	}

	if value.GetType() != forge.BOOLEAN {
		t.Error("value is not a BOOLEAN")
		return
	}

	rawVal := value.GetValue()
	switch rawVal.(type) {
	case bool:
		// this is what we want to happen
	default:
		t.Error("expected value.GetValue() to be a bool")
		return
	}

	if rawVal.(bool) != true {
		t.Error("expected value.GetValue() to be equal to 'true'")
	}
}
Example #2
0
func TestUpdateValueUnknown(t *testing.T) {
	t.Parallel()
	value, err := forge.NewPrimative("hello")
	if err != nil {
		t.Error(err)
		return
	}

	newVal := []string{"hello", "world"}
	err = value.UpdateValue(newVal)
	if err == nil {
		t.Error("expected an error, got none")
		return
	}
}