formatted

This commit is contained in:
David Dworken 2022-04-06 22:44:10 -07:00
parent 1065fff062
commit c48c4dc83f
4 changed files with 10 additions and 12 deletions

View File

@ -99,7 +99,7 @@ func query(query string) {
func displayBannerIfSet() error { func displayBannerIfSet() error {
config, err := lib.GetConfig() config, err := lib.GetConfig()
if err != nil { 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") url := lib.GetServerHostname() + "/api/v1/banner?commit_hash=" + GitCommit + "&device_id=" + config.DeviceId + "&forced_banner=" + os.Getenv("FORCED_BANNER")
resp, err := http.Get(url) resp, err := http.Get(url)
@ -156,4 +156,3 @@ func export() {
fmt.Println(entry) fmt.Println(entry)
} }
} }

View File

@ -2,13 +2,13 @@ package main
import ( import (
"bytes" "bytes"
"fmt"
"io/ioutil" "io/ioutil"
"os/exec"
"os" "os"
"os/exec"
"regexp" "regexp"
"strings" "strings"
"testing" "testing"
"fmt"
"github.com/ddworken/hishtory/shared" "github.com/ddworken/hishtory/shared"
) )
@ -50,7 +50,7 @@ func TestIntegrationWithNewDevice(t *testing.T) {
gvm use go1.17 gvm use go1.17
cd /home/david/code/hishtory/ cd /home/david/code/hishtory/
go build -o /tmp/client client/client.go 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) match, err := regexp.MatchString(`Setting secret hishtory key to .*`, out)
shared.Check(t, err) shared.Check(t, err)
if !match { if !match {
@ -131,7 +131,7 @@ func TestIntegrationWithNewDevice(t *testing.T) {
t.Fatalf("output has `echo mynewercommand` the wrong number of times") 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 { 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) t.Fatalf("status command has unexpected output: %#v", out)
} }
// Test the banner // Test the banner
os.Setenv("FORCED_BANNER", "HELLO_FROM_SERVER") os.Setenv("FORCED_BANNER", "HELLO_FROM_SERVER")
out = RunInteractiveBashCommands(t, `hishtory query`) out = RunInteractiveBashCommands(t, `hishtory query`)
if !strings.Contains(out, "HELLO_FROM_SERVER") { if !strings.Contains(out, "HELLO_FROM_SERVER") {

View File

@ -20,8 +20,8 @@ import (
"syscall" "syscall"
"time" "time"
"gorm.io/gorm"
"gorm.io/driver/sqlite" "gorm.io/driver/sqlite"
"gorm.io/gorm"
"github.com/fatih/color" "github.com/fatih/color"
"github.com/google/uuid" "github.com/google/uuid"
@ -123,7 +123,7 @@ func Setup(args []string) error {
} }
fmt.Println("Setting secret hishtory key to " + string(userSecret)) fmt.Println("Setting secret hishtory key to " + string(userSecret))
// Create and set the config // Create and set the config
var config ClientConfig var config ClientConfig
config.UserSecret = userSecret config.UserSecret = userSecret
config.IsEnabled = true config.IsEnabled = true
@ -133,7 +133,7 @@ func Setup(args []string) error {
return fmt.Errorf("failed to persist config to disk: %v", err) return fmt.Errorf("failed to persist config to disk: %v", err)
} }
// Drop all existing data // Drop all existing data
db, err := OpenLocalSqliteDb() db, err := OpenLocalSqliteDb()
if err != nil { if err != nil {
return fmt.Errorf("failed to open DB: %v", err) return fmt.Errorf("failed to open DB: %v", err)

View File

@ -71,7 +71,6 @@ func TestGetUserSecret(t *testing.T) {
} }
} }
func TestPersist(t *testing.T) { func TestPersist(t *testing.T) {
defer shared.BackupAndRestore(t)() defer shared.BackupAndRestore(t)()
db, err := OpenLocalSqliteDb() db, err := OpenLocalSqliteDb()
@ -114,4 +113,4 @@ func TestSearch(t *testing.T) {
if !shared.EntryEquals(*results[1], entry1) { if !shared.EntryEquals(*results[1], entry1) {
t.Fatalf("Search()[0]=%#v, expected: %#v", results[1], entry1) t.Fatalf("Search()[0]=%#v, expected: %#v", results[1], entry1)
} }
} }