Skip to content

Commit

Permalink
Fix deduplication task tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cluttrdev committed Oct 29, 2023
1 parent bb84d2b commit 6c38aee
Showing 1 changed file with 31 additions and 7 deletions.
38 changes: 31 additions & 7 deletions test/tasks/deduplicate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func TestPrepareDeduplicateQuery_Minimal(t *testing.T) {
Final: &[]bool{false}[0],
By: []string{},
Except: []string{},
ThrowIfNoop: &[]bool{false}[0],
ThrowIfNoop: nil,
}

expectedQuery := "OPTIMIZE TABLE {database:Identifier}.{table:Identifier} DEDUPLICATE"
Expand Down Expand Up @@ -75,7 +75,7 @@ func TestPrepareDeduplicateQuery_WithFinal(t *testing.T) {
Final: &[]bool{true}[0],
By: []string{},
Except: []string{},
ThrowIfNoop: &[]bool{false}[0],
ThrowIfNoop: nil,
}

expectedQuery := "OPTIMIZE TABLE {database:Identifier}.{table:Identifier} FINAL DEDUPLICATE"
Expand All @@ -90,7 +90,7 @@ func TestPrepareDeduplicateQuery_WithFinal(t *testing.T) {
checkParams(t, expectedParams, params)
}

func TestPrepareDeduplicateQuery_WithThrowIfNoop(t *testing.T) {
func TestPrepareDeduplicateQuery_WithThrowIfNoopTrue(t *testing.T) {
opt := tasks.DeduplicateTableOptions{
Database: "",
Table: "pipelines",
Expand All @@ -114,14 +114,38 @@ func TestPrepareDeduplicateQuery_WithThrowIfNoop(t *testing.T) {
checkParams(t, expectedParams, params)
}

func TestPrepareDeduplicateQuery_WithThrowIfNoopFalse(t *testing.T) {
opt := tasks.DeduplicateTableOptions{
Database: "",
Table: "pipelines",
Final: &[]bool{false}[0],
By: []string{},
Except: []string{},
ThrowIfNoop: &[]bool{false}[0],
}

expectedQuery := "" +
"OPTIMIZE TABLE {database:Identifier}.{table:Identifier} DEDUPLICATE" +
" SETTINGS optimize_throw_if_noop=0"
expectedParams := map[string]string{
"database": "gitlab_ci",
"table": "pipelines",
}

query, params := tasks.PrepareDeduplicateQuery(opt)

checkQuery(t, expectedQuery, query)
checkParams(t, expectedParams, params)
}

func TestPrepareDeduplicateQuery_WithBy(t *testing.T) {
opt := tasks.DeduplicateTableOptions{
Database: "",
Table: "pipelines",
Final: &[]bool{false}[0],
By: []string{"id", "project_id"},
Except: []string{},
ThrowIfNoop: &[]bool{false}[0],
ThrowIfNoop: nil,
}

expectedQuery := "" +
Expand All @@ -145,7 +169,7 @@ func TestPrepareDeduplicateQuery_WithSingleExcept(t *testing.T) {
Final: &[]bool{false}[0],
By: []string{},
Except: []string{"project_id"},
ThrowIfNoop: &[]bool{false}[0],
ThrowIfNoop: nil,
}

expectedQuery := "" +
Expand All @@ -169,7 +193,7 @@ func TestPrepareDeduplicateQuery_WithMultipleExcept(t *testing.T) {
Final: &[]bool{false}[0],
By: []string{},
Except: []string{"project_id", "status"},
ThrowIfNoop: &[]bool{false}[0],
ThrowIfNoop: nil,
}

expectedQuery := "" +
Expand All @@ -193,7 +217,7 @@ func TestPrepareDeduplicateQuery_WithByAndExcept(t *testing.T) {
Final: &[]bool{false}[0],
By: []string{"id"},
Except: []string{"project_id", "status"},
ThrowIfNoop: &[]bool{false}[0],
ThrowIfNoop: nil,
}

expectedQuery := "" +
Expand Down

0 comments on commit 6c38aee

Please sign in to comment.