Skip to content

Commit 7df58df

Browse files
authored
fix: Remove description from docs (#92)
We don't generate the descriptions anymore (I think), so we should not generate them with the docs. Also switched to snapshot testing so the output files are separated from the code. Another possible implementation is to add an option to enable/disable the description column ---
1 parent 619f55f commit 7df58df

File tree

4 files changed

+36
-51
lines changed

4 files changed

+36
-51
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
# Table: relation_table
3+
Description for relational table
4+
## Columns
5+
| Name | Type |
6+
| ------------- | ------------- |
7+
|string_col|String|
8+
|_cq_id|UUID|
9+
|_cq_fetch_time|Timestamp|
10+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
# Table: test_table
3+
Description for test table
4+
## Columns
5+
| Name | Type |
6+
| ------------- | ------------- |
7+
|int_col|Int|
8+
|_cq_id|UUID|
9+
|_cq_fetch_time|Timestamp|
10+

docs/source.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ const tableTmpl = `
1616
# Table: {{.Name}}
1717
{{ $.Description }}
1818
## Columns
19-
| Name | Type | Description |
20-
| ------------- | ------------- | ----- |
19+
| Name | Type |
20+
| ------------- | ------------- |
2121
{{- range $column := $.Columns }}
22-
|{{$column.Name}}|{{$column.Type | formatType}}|{{$column.Description|removeLineBreaks}}|
22+
|{{$column.Name}}|{{$column.Type | formatType}}|
2323
{{- end }}
2424
`
2525

docs/source_test.go

Lines changed: 13 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ import (
66
"path"
77
"testing"
88

9+
"github.com/bradleyjkemp/cupaloy/v2"
910
"github.com/cloudquery/plugin-sdk/plugins"
1011
"github.com/cloudquery/plugin-sdk/schema"
1112
"github.com/cloudquery/plugin-sdk/specs"
12-
"github.com/google/go-cmp/cmp"
1313
"github.com/rs/zerolog"
14+
"github.com/stretchr/testify/require"
1415
)
1516

1617
type testExecutionClient struct {
@@ -23,9 +24,8 @@ var testTables = []*schema.Table{
2324
Description: "Description for test table",
2425
Columns: []schema.Column{
2526
{
26-
Name: "int_col",
27-
Type: schema.TypeInt,
28-
Description: "Int column",
27+
Name: "int_col",
28+
Type: schema.TypeInt,
2929
},
3030
},
3131
Relations: []*schema.Table{
@@ -34,48 +34,15 @@ var testTables = []*schema.Table{
3434
Description: "Description for relational table",
3535
Columns: []schema.Column{
3636
{
37-
Name: "string_col",
38-
Type: schema.TypeString,
39-
Description: "String column",
37+
Name: "string_col",
38+
Type: schema.TypeString,
4039
},
4140
},
4241
},
4342
},
4443
},
4544
}
4645

47-
var expectFiles = []struct {
48-
Name string
49-
Content string
50-
}{
51-
{
52-
Name: "test_table.md",
53-
Content: `
54-
# Table: test_table
55-
Description for test table
56-
## Columns
57-
| Name | Type | Description |
58-
| ------------- | ------------- | ----- |
59-
|int_col|Int|Int column|
60-
|_cq_id|UUID|Internal CQ ID of the row|
61-
|_cq_fetch_time|Timestamp|Internal CQ row of when fetch was started (this will be the same for all rows in a single fetch)|
62-
`,
63-
},
64-
{
65-
Name: "relation_table.md",
66-
Content: `
67-
# Table: relation_table
68-
Description for relational table
69-
## Columns
70-
| Name | Type | Description |
71-
| ------------- | ------------- | ----- |
72-
|string_col|String|String column|
73-
|_cq_id|UUID|Internal CQ ID of the row|
74-
|_cq_fetch_time|Timestamp|Internal CQ row of when fetch was started (this will be the same for all rows in a single fetch)|
75-
`,
76-
},
77-
}
78-
7946
func (c *testExecutionClient) Logger() *zerolog.Logger {
8047
return &c.logger
8148
}
@@ -97,15 +64,13 @@ func TestGenerateSourcePluginDocs(t *testing.T) {
9764
t.Fatalf("unexpected error calling GenerateSourcePluginDocs: %v", err)
9865
}
9966

67+
expectFiles := []string{"test_table.md", "relation_table.md"}
10068
for _, exp := range expectFiles {
101-
output := path.Join(tmpdir, exp.Name)
102-
got, err := os.ReadFile(output)
103-
if err != nil {
104-
t.Fatalf("error reading %q: %v ", exp.Name, err)
105-
}
106-
107-
if diff := cmp.Diff(string(got), exp.Content); diff != "" {
108-
t.Errorf("Generate docs for %q not as expected (+got, -want): %v", exp.Name, diff)
109-
}
69+
t.Run(exp, func(t *testing.T) {
70+
output := path.Join(tmpdir, exp)
71+
got, err := os.ReadFile(output)
72+
require.NoError(t, err)
73+
cupaloy.SnapshotT(t, got)
74+
})
11075
}
11176
}

0 commit comments

Comments
 (0)