MCPcopy Index your code
hub / github.com/cloudquery/cloudquery / TestSyncSummaryPascalCase

Function TestSyncSummaryPascalCase

cli/cmd/sync_test.go:714–748  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

712}
713
714func TestSyncSummaryPascalCase(t *testing.T) {
715 summaryTable, err := generateSummaryTable()
716 require.NoError(t, err)
717
718 cols := make(map[string]struct{}, len(summaryTable.Columns))
719 for _, col := range summaryTable.Columns {
720 cols[col.Name] = struct{}{}
721 }
722
723 summType := reflect.TypeOf(syncSummary{})
724 jsonTags := make(map[string]struct{})
725 for i := 0; i < summType.NumField(); i++ {
726 field := summType.Field(i)
727 jsonTag := field.Tag.Get("json")
728 if jsonTag == "" {
729 // If no json tag, use field name (lowercase)
730 jsonTag = strings.ToLower(field.Name)
731 } else {
732 if commaIdx := strings.Index(jsonTag, ","); commaIdx != -1 {
733 jsonTag = jsonTag[:commaIdx]
734 }
735 if jsonTag == "-" {
736 continue
737 }
738 }
739
740 jsonTags[jsonTag] = struct{}{}
741 }
742 delete(jsonTags, "sync_group_id")
743 delete(jsonTags, "sync_time")
744
745 if diff := cmp.Diff(cols, jsonTags); diff != "" {
746 t.Fatalf("syncSummary JSON tags don't match field names (-want +got):\n%s", diff)
747 }
748}
749
750func readSummaries(t *testing.T, filename string) []syncSummary {
751 p, err := os.ReadFile(filename)

Callers

nothing calls this directly

Calls 2

generateSummaryTableFunction · 0.85
GetMethod · 0.45

Tested by

no test coverage detected