mirror of
https://github.com/ddworken/hishtory.git
synced 2025-06-12 08:06:53 +02:00
Fix hishtory status tests + optimize switchToDevice() function
This commit is contained in:
parent
3cffa25c1e
commit
dddee9eeff
@ -265,7 +265,7 @@ func testBasicUserFlow(t *testing.T, tester shellTester) string {
|
|||||||
|
|
||||||
// Test the status subcommand
|
// Test the status subcommand
|
||||||
out := tester.RunInteractiveShell(t, `hishtory status`)
|
out := tester.RunInteractiveShell(t, `hishtory status`)
|
||||||
if out != fmt.Sprintf("Hishtory: v0.Unknown\nEnabled: true\nSecret Key: %s\nCommit Hash: Unknown\n", userSecret) {
|
if out != fmt.Sprintf("hiSHtory: v0.Unknown\nEnabled: true\nSecret Key: %s\nCommit Hash: Unknown\n", userSecret) {
|
||||||
t.Fatalf("status command has unexpected output: %#v", out)
|
t.Fatalf("status command has unexpected output: %#v", out)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -601,7 +601,7 @@ func testUpdate(t *testing.T, tester shellTester) {
|
|||||||
|
|
||||||
// Check the status command
|
// Check the status command
|
||||||
out := tester.RunInteractiveShell(t, `hishtory status`)
|
out := tester.RunInteractiveShell(t, `hishtory status`)
|
||||||
if out != fmt.Sprintf("Hishtory: v0.Unknown\nEnabled: true\nSecret Key: %s\nCommit Hash: Unknown\n", userSecret) {
|
if out != fmt.Sprintf("hiSHtory: v0.Unknown\nEnabled: true\nSecret Key: %s\nCommit Hash: Unknown\n", userSecret) {
|
||||||
t.Fatalf("status command has unexpected output: %#v", out)
|
t.Fatalf("status command has unexpected output: %#v", out)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -645,7 +645,7 @@ func testRepeatedCommandThenQuery(t *testing.T, tester shellTester) {
|
|||||||
|
|
||||||
// Check the status command
|
// Check the status command
|
||||||
out := tester.RunInteractiveShell(t, `hishtory status`)
|
out := tester.RunInteractiveShell(t, `hishtory status`)
|
||||||
if out != fmt.Sprintf("Hishtory: v0.Unknown\nEnabled: true\nSecret Key: %s\nCommit Hash: Unknown\n", userSecret) {
|
if out != fmt.Sprintf("hiSHtory: v0.Unknown\nEnabled: true\nSecret Key: %s\nCommit Hash: Unknown\n", userSecret) {
|
||||||
t.Fatalf("status command has unexpected output: %#v", out)
|
t.Fatalf("status command has unexpected output: %#v", out)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -682,7 +682,7 @@ func testRepeatedCommandAndQuery(t *testing.T, tester shellTester) {
|
|||||||
|
|
||||||
// Check the status command
|
// Check the status command
|
||||||
out := tester.RunInteractiveShell(t, `hishtory status`)
|
out := tester.RunInteractiveShell(t, `hishtory status`)
|
||||||
if out != fmt.Sprintf("Hishtory: v0.Unknown\nEnabled: true\nSecret Key: %s\nCommit Hash: Unknown\n", userSecret) {
|
if out != fmt.Sprintf("hiSHtory: v0.Unknown\nEnabled: true\nSecret Key: %s\nCommit Hash: Unknown\n", userSecret) {
|
||||||
t.Fatalf("status command has unexpected output: %#v", out)
|
t.Fatalf("status command has unexpected output: %#v", out)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -905,7 +905,7 @@ CGO_ENABLED=0 go build -o /tmp/client
|
|||||||
|
|
||||||
// Test the status subcommand
|
// Test the status subcommand
|
||||||
out = tester.RunInteractiveShell(t, `hishtory status`)
|
out = tester.RunInteractiveShell(t, `hishtory status`)
|
||||||
if out != fmt.Sprintf("Hishtory: v0.Unknown\nEnabled: true\nSecret Key: %s\nCommit Hash: Unknown\n", userSecret) {
|
if out != fmt.Sprintf("hiSHtory: v0.Unknown\nEnabled: true\nSecret Key: %s\nCommit Hash: Unknown\n", userSecret) {
|
||||||
t.Fatalf("status command has unexpected output: %#v", out)
|
t.Fatalf("status command has unexpected output: %#v", out)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1106,7 +1106,7 @@ func testInstallViaPythonScript(t *testing.T, tester shellTester) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
out = tester.RunInteractiveShell(t, `hishtory status`)
|
out = tester.RunInteractiveShell(t, `hishtory status`)
|
||||||
expectedOut := fmt.Sprintf("Hishtory: %s\nEnabled: true\nSecret Key: %s\nCommit Hash: ", downloadData.Version, userSecret)
|
expectedOut := fmt.Sprintf("hiSHtory: %s\nEnabled: true\nSecret Key: %s\nCommit Hash: ", downloadData.Version, userSecret)
|
||||||
if !strings.Contains(out, expectedOut) {
|
if !strings.Contains(out, expectedOut) {
|
||||||
t.Fatalf("status command has unexpected output: actual=%#v, expected=%#v", out, expectedOut)
|
t.Fatalf("status command has unexpected output: actual=%#v, expected=%#v", out, expectedOut)
|
||||||
}
|
}
|
||||||
@ -1558,6 +1558,9 @@ func createDevice(t *testing.T, tester shellTester, devices *deviceSet, key, dev
|
|||||||
}
|
}
|
||||||
|
|
||||||
func switchToDevice(devices *deviceSet, d device) {
|
func switchToDevice(devices *deviceSet, d device) {
|
||||||
|
if devices.currentDevice != nil && d == *devices.currentDevice {
|
||||||
|
return
|
||||||
|
}
|
||||||
if devices.currentDevice != nil {
|
if devices.currentDevice != nil {
|
||||||
(*devices.deviceMap)[*devices.currentDevice].backup()
|
(*devices.deviceMap)[*devices.currentDevice].backup()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user