Skip to content

Commit

Permalink
dm: refine instrunction (#8556)
Browse files Browse the repository at this point in the history
ref #4287
  • Loading branch information
D3Hunter authored Mar 17, 2023
1 parent a59888c commit 745fe12
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion dm/pkg/checker/table_structure.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,11 @@ func (c *TablesChecker) handleOpts(r *Result) (func(options []*incompatibilityOp
}
}
}, func() {
instructionSlice := make([]string, 0, len(resultInstructions))
for k := range resultInstructions {
r.Instruction += k + "; "
instructionSlice = append(instructionSlice, k)
}
r.Instruction += strings.Join(instructionSlice, "; ")
}
}

Expand Down
4 changes: 4 additions & 0 deletions dm/pkg/checker/table_structure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ package checker

import (
"context"
"strings"
"testing"

"github.com/DATA-DOG/go-sqlmock"
Expand Down Expand Up @@ -217,6 +218,7 @@ func TestTablesChecker(t *testing.T) {
require.Len(t, result.Errors, 2)
require.NoError(t, mock.ExpectationsWereMet())
require.NoError(t, downMock.ExpectationsWereMet())
require.False(t, strings.HasSuffix(result.Instruction, "; "))

// 3. test #5759

Expand Down Expand Up @@ -311,6 +313,7 @@ func TestTablesChecker(t *testing.T) {
result.Errors[4].ShortErr)
require.NoError(t, mock.ExpectationsWereMet())
require.NoError(t, downMock.ExpectationsWereMet())
require.False(t, strings.HasSuffix(result.Instruction, "; "))

// 5. check extended columns
commonMock()
Expand Down Expand Up @@ -346,6 +349,7 @@ func TestTablesChecker(t *testing.T) {
result = checker.Check(ctx)
require.Equal(t, StateFailure, result.State)
require.Len(t, result.Errors, 2)
require.False(t, strings.HasSuffix(result.Instruction, "; "))
require.Equal(t,
"table `test-db`.`test-table-1` upstream table must not contain extended column [ext1]",
result.Errors[0].ShortErr)
Expand Down

0 comments on commit 745fe12

Please sign in to comment.