Fix issues with Repository synchronization tool (#124)
* Only run tests in build/sync if directory exists * Use t.Helper() * Don't compare size of directories * Fix TestFileHistory * Fix linter issue * Apply changes from https://github.com/mattermost/mattermost-plugin-github/pull/345 * Use ts file for tests * Add sync target
This commit is contained in:
parent
0688e8df4c
commit
dcaf9dd289
11 changed files with 776 additions and 12 deletions
|
@ -26,7 +26,7 @@ func TestCopyDirectory(t *testing.T) {
|
|||
err = plan.CopyDirectory(srcDir, dir)
|
||||
assert.Nil(err)
|
||||
|
||||
compareDirectories(assert, dir, srcDir)
|
||||
compareDirectories(t, dir, srcDir)
|
||||
}
|
||||
|
||||
func TestOverwriteFileAction(t *testing.T) {
|
||||
|
@ -55,7 +55,7 @@ func TestOverwriteFileAction(t *testing.T) {
|
|||
err = action.Run("c", setup)
|
||||
assert.Nil(err)
|
||||
|
||||
compareDirectories(assert, dir, filepath.Join(wd, "testdata", "b"))
|
||||
compareDirectories(t, dir, filepath.Join(wd, "testdata", "b"))
|
||||
}
|
||||
|
||||
func TestOverwriteDirectoryAction(t *testing.T) {
|
||||
|
@ -86,10 +86,13 @@ func TestOverwriteDirectoryAction(t *testing.T) {
|
|||
|
||||
destDir := filepath.Join(dir, "testdata")
|
||||
srcDir := filepath.Join(wd, "testdata")
|
||||
compareDirectories(assert, destDir, srcDir)
|
||||
compareDirectories(t, destDir, srcDir)
|
||||
}
|
||||
|
||||
func compareDirectories(assert *assert.Assertions, pathA, pathB string) {
|
||||
func compareDirectories(t *testing.T, pathA, pathB string) {
|
||||
assert := assert.New(t)
|
||||
t.Helper()
|
||||
|
||||
aContents, err := ioutil.ReadDir(pathA)
|
||||
assert.Nil(err)
|
||||
bContents, err := ioutil.ReadDir(pathB)
|
||||
|
@ -100,8 +103,10 @@ func compareDirectories(assert *assert.Assertions, pathA, pathB string) {
|
|||
for i, aFInfo := range aContents {
|
||||
bFInfo := bContents[i]
|
||||
assert.Equal(aFInfo.Name(), bFInfo.Name())
|
||||
assert.Equal(aFInfo.Size(), bFInfo.Size())
|
||||
assert.Equal(aFInfo.Mode(), bFInfo.Mode())
|
||||
assert.Equal(aFInfo.IsDir(), bFInfo.IsDir())
|
||||
if !aFInfo.IsDir() {
|
||||
assert.Equal(aFInfo.Size(), bFInfo.Size())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue