-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathpredicate_test.go
43 lines (38 loc) · 1.21 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
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.PredicateTypeEnumExists}
// 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.PredicateTypeEnumContains,
Value: ol.RefOf("go"),
}
// Act
marshalledNullPredicate, err := json.Marshal(outputWithValue)
autopilot.Ok(t, err)
autopilot.Equals(t, predicateWithValue, string(marshalledNullPredicate))
}