github.com/confluentinc/cli@v1.100.0/test/audit_log_config_spec_test.go (about) 1 package test 2 3 import ( 4 "encoding/json" 5 "regexp" 6 7 mds "github.com/confluentinc/mds-sdk-go/mdsv1" 8 ) 9 10 func (s *CLITestSuite) TestAuditLogConfigSpecSerialization() { 11 original := LoadFixture(s.T(), "auditlogconfig-roundtrip-fixedpoint.golden") 12 originalBytes := []byte(original) 13 spec := mds.AuditLogConfigSpec{} 14 if err := json.Unmarshal(originalBytes, &spec); err != nil { 15 s.T().Fatal(err) 16 } 17 roundTripBytes, err := json.MarshalIndent(spec, "", " ") 18 if err != nil { 19 s.T().Fatal(err) 20 } 21 roundTrip := string(roundTripBytes) 22 23 re := regexp.MustCompile(`[\r\n]+`) 24 25 if re.ReplaceAllString(original, "") != re.ReplaceAllString(roundTrip, "") { 26 s.T().Fail() 27 } 28 }