diff --git a/client/client.go b/client/client.go index c017a8f..af9ec37 100644 --- a/client/client.go +++ b/client/client.go @@ -99,7 +99,7 @@ func query(query string) { func displayBannerIfSet() error { config, err := lib.GetConfig() if err != nil { - return fmt.Errorf("failed to get config: %v", err) + return fmt.Errorf("failed to get config: %v", err) } url := lib.GetServerHostname() + "/api/v1/banner?commit_hash=" + GitCommit + "&device_id=" + config.DeviceId + "&forced_banner=" + os.Getenv("FORCED_BANNER") resp, err := http.Get(url) @@ -156,4 +156,3 @@ func export() { fmt.Println(entry) } } - diff --git a/client/client_test.go b/client/client_test.go index 1eed739..910f2ff 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -2,13 +2,13 @@ package main import ( "bytes" + "fmt" "io/ioutil" - "os/exec" "os" + "os/exec" "regexp" "strings" "testing" - "fmt" "github.com/ddworken/hishtory/shared" ) @@ -50,7 +50,7 @@ func TestIntegrationWithNewDevice(t *testing.T) { gvm use go1.17 cd /home/david/code/hishtory/ go build -o /tmp/client client/client.go - /tmp/client install ` + userSecret) + /tmp/client install `+userSecret) match, err := regexp.MatchString(`Setting secret hishtory key to .*`, out) shared.Check(t, err) if !match { @@ -131,7 +131,7 @@ func TestIntegrationWithNewDevice(t *testing.T) { t.Fatalf("output has `echo mynewercommand` the wrong number of times") } - // TODO: Test the live update flow + // Manually submit an event that is tied to the second user, and then we'll check if we see it for the third user } func testIntegration(t *testing.T) string { @@ -156,7 +156,7 @@ func testIntegration(t *testing.T) string { t.Fatalf("status command has unexpected output: %#v", out) } - // Test the banner + // Test the banner os.Setenv("FORCED_BANNER", "HELLO_FROM_SERVER") out = RunInteractiveBashCommands(t, `hishtory query`) if !strings.Contains(out, "HELLO_FROM_SERVER") { diff --git a/client/lib/lib.go b/client/lib/lib.go index 1396e6d..6653bb0 100644 --- a/client/lib/lib.go +++ b/client/lib/lib.go @@ -20,8 +20,8 @@ import ( "syscall" "time" - "gorm.io/gorm" "gorm.io/driver/sqlite" + "gorm.io/gorm" "github.com/fatih/color" "github.com/google/uuid" @@ -123,7 +123,7 @@ func Setup(args []string) error { } fmt.Println("Setting secret hishtory key to " + string(userSecret)) - // Create and set the config + // Create and set the config var config ClientConfig config.UserSecret = userSecret config.IsEnabled = true @@ -133,7 +133,7 @@ func Setup(args []string) error { return fmt.Errorf("failed to persist config to disk: %v", err) } - // Drop all existing data + // Drop all existing data db, err := OpenLocalSqliteDb() if err != nil { return fmt.Errorf("failed to open DB: %v", err) diff --git a/client/lib/lib_test.go b/client/lib/lib_test.go index ad6a595..1fc3c83 100644 --- a/client/lib/lib_test.go +++ b/client/lib/lib_test.go @@ -71,7 +71,6 @@ func TestGetUserSecret(t *testing.T) { } } - func TestPersist(t *testing.T) { defer shared.BackupAndRestore(t)() db, err := OpenLocalSqliteDb() @@ -114,4 +113,4 @@ func TestSearch(t *testing.T) { if !shared.EntryEquals(*results[1], entry1) { t.Fatalf("Search()[0]=%#v, expected: %#v", results[1], entry1) } -} \ No newline at end of file +}