Skip to content
Merged
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
12 changes: 11 additions & 1 deletion go/test/endtoend/reparent/plannedreparent/reparent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"context"
"fmt"
"strconv"
"strings"
"testing"
"time"

Expand Down Expand Up @@ -557,7 +558,16 @@ func waitForFilePosition(t *testing.T, clusterInstance *cluster.LocalProcessClus

// fileNameFromPosition gets the file name from the position
func fileNameFromPosition(pos string) string {
return pos[0 : len(pos)-4]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, this was assuming there were 3 position digits this whole time? 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mattlord yeah strange! 🙈

s := strings.SplitN(pos, ":", 2)
if len(s) != 2 {
return ""
}
return s[0]
}

func TestFileNameFromPosition(t *testing.T) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is testing a test-helper, which may be overkill. Happy to remove this 👍

assert.Equal(t, "", fileNameFromPosition("shouldfail"))
assert.Equal(t, "FilePos/vt-0000000101-bin.000001", fileNameFromPosition("FilePos/vt-0000000101-bin.000001:123456789"))
}

// rowNumberFromPosition gets the row number from the position
Expand Down