Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added go-fmt gate check #77

Merged
merged 7 commits into from
Feb 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ jobs:
- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Check Format
run: if [ "$(gofmt -d -s -l . | tee /dev/fd/2 | wc -l)" -gt 0 ]; then exit 1; fi

- name: Get dependencies
run: |
cd kusto
Expand Down
2 changes: 1 addition & 1 deletion kusto/internal/frames/unmarshal/unmarshal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func TestUnmarshalRows(t *testing.T) {
}

for _, test := range tests {
rows, err := Rows(table.Columns{table.Column{Name: "store", Type: test.columnType}}, [][]interface{}{[]interface{}{test.value}})
rows, err := Rows(table.Columns{table.Column{Name: "store", Type: test.columnType}}, [][]interface{}{{test.value}})
if err != nil {
t.Errorf("TestUnmarshalRows(%v): got err == %s, want err == nil", test.value, err)
continue
Expand Down
4 changes: 2 additions & 2 deletions kusto/mock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ func TestRow(t *testing.T) {
value.Values{value.Int{Value: 1, Valid: true}, value.String{}, value.Long{}},
},
want: []value.Values{
value.Values{value.Int{Value: 2, Valid: true}, value.String{}, value.Long{}},
value.Values{value.Int{Value: 1, Valid: true}, value.String{}, value.Long{}},
{value.Int{Value: 2, Valid: true}, value.String{}, value.Long{}},
{value.Int{Value: 1, Valid: true}, value.String{}, value.Long{}},
},
},
}
Expand Down
38 changes: 19 additions & 19 deletions kusto/query_builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ func TestDefinitions(t *testing.T) {
}

clone := params.clone()
clone.With(map[string]ParamType{"hellyeah": ParamType{Type: types.Bool}})
clone.With(map[string]ParamType{"hellyeah": {Type: types.Bool}})

if _, ok := params.m["hellyeah"]; ok {
t.Errorf("TestParameters(%s): clone modification modified original", test.desc)
Expand All @@ -305,109 +305,109 @@ func TestParameters(t *testing.T) {
}{
{
desc: "Value key doesn't exist in Parameters",
qParams: NewDefinitions().Must(map[string]ParamType{"key1": ParamType{Type: types.Bool}}),
qParams: NewDefinitions().Must(map[string]ParamType{"key1": {Type: types.Bool}}),
qValues: NewParameters().Must(map[string]interface{}{"key2": true}),
err: true,
},
{
desc: "Should be time.Time, isn't",
qParams: NewDefinitions().Must(map[string]ParamType{"key1": ParamType{Type: types.DateTime}}),
qParams: NewDefinitions().Must(map[string]ParamType{"key1": {Type: types.DateTime}}),
qValues: NewParameters().Must(map[string]interface{}{"key1": 1}),
err: true,
},
{
desc: "Should be uuid.UUID, isn't",
qParams: NewDefinitions().Must(map[string]ParamType{"key1": ParamType{Type: types.GUID}}),
qParams: NewDefinitions().Must(map[string]ParamType{"key1": {Type: types.GUID}}),
qValues: NewParameters().Must(map[string]interface{}{"key1": 1}),
err: true,
},
{
desc: "Should be int32, isn't",
qParams: NewDefinitions().Must(map[string]ParamType{"key1": ParamType{Type: types.Int}}),
qParams: NewDefinitions().Must(map[string]ParamType{"key1": {Type: types.Int}}),
qValues: NewParameters().Must(map[string]interface{}{"key1": int64(1)}),
err: true,
},
{
desc: "Should be int64, isn't",
qParams: NewDefinitions().Must(map[string]ParamType{"key1": ParamType{Type: types.Long}}),
qParams: NewDefinitions().Must(map[string]ParamType{"key1": {Type: types.Long}}),
qValues: NewParameters().Must(map[string]interface{}{"key1": int32(1)}),
err: true,
},
{
desc: "Should be float64, isn't",
qParams: NewDefinitions().Must(map[string]ParamType{"key1": ParamType{Type: types.Real}}),
qParams: NewDefinitions().Must(map[string]ParamType{"key1": {Type: types.Real}}),
qValues: NewParameters().Must(map[string]interface{}{"key1": 1}),
err: true,
},
{
desc: "Should be string, isn't",
qParams: NewDefinitions().Must(map[string]ParamType{"key1": ParamType{Type: types.String}}),
qParams: NewDefinitions().Must(map[string]ParamType{"key1": {Type: types.String}}),
qValues: NewParameters().Must(map[string]interface{}{"key1": 1}),
err: true,
},
{
desc: "Should be time.Duration, isn't",
qParams: NewDefinitions().Must(map[string]ParamType{"key1": ParamType{Type: types.Timespan}}),
qParams: NewDefinitions().Must(map[string]ParamType{"key1": {Type: types.Timespan}}),
qValues: NewParameters().Must(map[string]interface{}{"key1": 1}),
err: true,
},
{
desc: "Should be string representing decimal or *big.Float, isn't",
qParams: NewDefinitions().Must(map[string]ParamType{"key1": ParamType{Type: types.Decimal}}),
qParams: NewDefinitions().Must(map[string]ParamType{"key1": {Type: types.Decimal}}),
qValues: NewParameters().Must(map[string]interface{}{"key1": 1}),
err: true,
},
{
desc: "Success time.Time",
qParams: NewDefinitions().Must(map[string]ParamType{"key1": ParamType{Type: types.DateTime}}),
qParams: NewDefinitions().Must(map[string]ParamType{"key1": {Type: types.DateTime}}),
qValues: NewParameters().Must(map[string]interface{}{"key1": now}),
want: map[string]string{"key1": fmt.Sprintf("datetime(%s)", now.Format(time.RFC3339Nano))},
},
{
desc: "Success uuid.UUID",
qParams: NewDefinitions().Must(map[string]ParamType{"key1": ParamType{Type: types.GUID}}),
qParams: NewDefinitions().Must(map[string]ParamType{"key1": {Type: types.GUID}}),
qValues: NewParameters().Must(map[string]interface{}{"key1": uu}),
want: map[string]string{"key1": fmt.Sprintf("guid(%s)", uu.String())},
},
{
desc: "Success int32",
qParams: NewDefinitions().Must(map[string]ParamType{"key1": ParamType{Type: types.Int}}),
qParams: NewDefinitions().Must(map[string]ParamType{"key1": {Type: types.Int}}),
qValues: NewParameters().Must(map[string]interface{}{"key1": int32(1)}),
want: map[string]string{"key1": fmt.Sprintf("int(%d)", 1)},
},
{
desc: "Success int64",
qParams: NewDefinitions().Must(map[string]ParamType{"key1": ParamType{Type: types.Long}}),
qParams: NewDefinitions().Must(map[string]ParamType{"key1": {Type: types.Long}}),
qValues: NewParameters().Must(map[string]interface{}{"key1": int64(1)}),
want: map[string]string{"key1": fmt.Sprintf("long(%d)", 1)},
},
{
desc: "Success float64",
qParams: NewDefinitions().Must(map[string]ParamType{"key1": ParamType{Type: types.Real}}),
qParams: NewDefinitions().Must(map[string]ParamType{"key1": {Type: types.Real}}),
qValues: NewParameters().Must(map[string]interface{}{"key1": 1.1}),
want: map[string]string{"key1": fmt.Sprintf("real(%f)", 1.1)},
},
{
desc: "Success string",
qParams: NewDefinitions().Must(map[string]ParamType{"key1": ParamType{Type: types.String}}),
qParams: NewDefinitions().Must(map[string]ParamType{"key1": {Type: types.String}}),
qValues: NewParameters().Must(map[string]interface{}{"key1": "string"}),
want: map[string]string{"key1": "string"},
},
{
desc: "Success time.Duration",
qParams: NewDefinitions().Must(map[string]ParamType{"key1": ParamType{Type: types.Timespan}}),
qParams: NewDefinitions().Must(map[string]ParamType{"key1": {Type: types.Timespan}}),
qValues: NewParameters().Must(map[string]interface{}{"key1": 3 * time.Second}),
want: map[string]string{"key1": "timespan(00:00:03)"},
},
{
desc: "Success string representing decimal",
qParams: NewDefinitions().Must(map[string]ParamType{"key1": ParamType{Type: types.Decimal}}),
qParams: NewDefinitions().Must(map[string]ParamType{"key1": {Type: types.Decimal}}),
qValues: NewParameters().Must(map[string]interface{}{"key1": "1.3"}),
want: map[string]string{"key1": fmt.Sprintf("decimal(%s)", "1.3")},
},
{
desc: "Success *big.Float",
qParams: NewDefinitions().Must(map[string]ParamType{"key1": ParamType{Type: types.Decimal}}),
qParams: NewDefinitions().Must(map[string]ParamType{"key1": {Type: types.Decimal}}),
qValues: NewParameters().Must(map[string]interface{}{"key1": big.NewFloat(3.2)}),
want: map[string]string{"key1": fmt.Sprintf("decimal(%s)", big.NewFloat(3.2).String())},
},
Expand Down