2018-05-15 21:13:11 +00:00
|
|
|
package model
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"strings"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestMarshal(t *testing.T) {
|
|
|
|
d := Data{
|
|
|
|
Tickets: []*Ticket{
|
2021-10-19 19:05:25 +00:00
|
|
|
{
|
2018-05-15 21:13:11 +00:00
|
|
|
ID: "t1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Audits: []*Audit{
|
2021-10-19 19:05:25 +00:00
|
|
|
{
|
2018-05-15 21:13:11 +00:00
|
|
|
ID: "a1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Procedures: []*Procedure{
|
2021-10-19 19:05:25 +00:00
|
|
|
{
|
|
|
|
ID: "pro1",
|
2018-05-15 21:13:11 +00:00
|
|
|
},
|
|
|
|
},
|
2021-10-19 19:05:25 +00:00
|
|
|
Policies: []*Document{
|
|
|
|
{
|
2018-05-15 21:13:11 +00:00
|
|
|
Name: "pol1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
m, _ := json.Marshal(d)
|
|
|
|
encoded := string(m)
|
|
|
|
if !strings.Contains(encoded, "t1") ||
|
|
|
|
!strings.Contains(encoded, "a1") ||
|
|
|
|
!strings.Contains(encoded, "pro1") ||
|
|
|
|
!strings.Contains(encoded, "pol1") {
|
|
|
|
t.Error("identifier not found in marshalled string")
|
|
|
|
}
|
|
|
|
}
|