-
Notifications
You must be signed in to change notification settings - Fork 13
/
predicate_test.go
45 lines (40 loc) · 1.24 KB
/
predicate_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package opslevel_test
import (
"encoding/json"
"testing"
ol "github.com/opslevel/opslevel-go/v2024"
"github.com/rocktavious/autopilot/v2023"
)
func TestJsonMarshalPredicateUpdateInputNull(t *testing.T) {
// Arrange
predicateNull := "null"
outputNull := &ol.PredicateUpdateInput{}
// Act
marshalledNullPredicate, err := json.Marshal(outputNull)
// Assert
autopilot.Ok(t, err)
autopilot.Equals(t, predicateNull, string(marshalledNullPredicate))
}
func TestJsonMarshalPredicateUpdateInputNoValue(t *testing.T) {
// Arrange
predicateNoValue := `{"type":"exists"}`
outputNoValue := &ol.PredicateUpdateInput{
Type: ol.RefOf(ol.PredicateTypeEnum("exists")),
}
// Act
marshalledNullPredicate, err := json.Marshal(outputNoValue)
autopilot.Ok(t, err)
autopilot.Equals(t, predicateNoValue, string(marshalledNullPredicate))
}
func TestJsonMarshalPredicateUpdateInputWithValue(t *testing.T) {
// Arrange
predicateWithValue := `{"type":"contains","value":"go"}`
outputWithValue := &ol.PredicateUpdateInput{
Type: ol.RefOf(ol.PredicateTypeEnum("contains")),
Value: ol.RefOf("go"),
}
// Act
marshalledNullPredicate, err := json.Marshal(outputWithValue)
autopilot.Ok(t, err)
autopilot.Equals(t, predicateWithValue, string(marshalledNullPredicate))
}