-
Notifications
You must be signed in to change notification settings - Fork 432
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(engine): engine database upgrade improvement (#3811)
downloads sql.tar.gz from github release corresponding to the current engine version close #1899
- Loading branch information
Showing
5 changed files
with
179 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package database | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
) | ||
|
||
func Test_downloadSQLTarGz(t *testing.T) { | ||
type args struct { | ||
currentVersion string | ||
artifactName string | ||
migrateDir string | ||
} | ||
tmpMigrateDir := os.TempDir() | ||
tests := []struct { | ||
name string | ||
args args | ||
wantErr bool | ||
}{ | ||
{ | ||
name: "valid version", | ||
args: args{currentVersion: "0.37.3+cds.7708", artifactName: "sql.tar.gz", migrateDir: tmpMigrateDir}, | ||
wantErr: false, | ||
}, { | ||
name: "valid version, invalid dir", | ||
args: args{currentVersion: "0.37.3+cds.7708", artifactName: "sql.tar.gz", migrateDir: "/tmp/foo"}, | ||
wantErr: true, | ||
}, { | ||
name: "invalid artifact name", | ||
args: args{currentVersion: "0.37.3+cds.7708", artifactName: "test-artifact.tar.gz", migrateDir: tmpMigrateDir}, | ||
wantErr: true, | ||
}, { | ||
name: "invalid version without '+'", | ||
args: args{currentVersion: "0.37.3", artifactName: "sql.tar.gz", migrateDir: tmpMigrateDir}, | ||
wantErr: true, | ||
}, { | ||
name: "invalid version", | ||
args: args{currentVersion: "foo", artifactName: "sql.tar.gz", migrateDir: tmpMigrateDir}, | ||
wantErr: true, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
if err := downloadSQLTarGz(tt.args.currentVersion, tt.args.artifactName, tt.args.migrateDir); (err != nil) != tt.wantErr { | ||
t.Errorf("downloadSQLTarGz() error = %v, wantErr %v", err, tt.wantErr) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters