mirror of
https://github.com/ddworken/hishtory.git
synced 2025-02-23 05:51:08 +01:00
fixed export, added tests for it, made tests more accurate, and excluded things from gitignore
This commit is contained in:
parent
7a6aece6dc
commit
581231d0ef
5
.gitignore
vendored
5
.gitignore
vendored
@ -1,4 +1 @@
|
|||||||
client
|
web/landing/www/binaries/hishtory-linux
|
||||||
server
|
|
||||||
!client/
|
|
||||||
!server/
|
|
||||||
|
2
Makefile
2
Makefile
@ -2,7 +2,7 @@ test:
|
|||||||
HISHTORY_TEST=1 go test -p 1 ./...
|
HISHTORY_TEST=1 go test -p 1 ./...
|
||||||
|
|
||||||
build-binary:
|
build-binary:
|
||||||
go build -o web/landing/www/binaries/hishtory-linux -ldflags "-X main.GitCommit=`git rev-list -1 HEAD`" client/client.go
|
go build -trimpath -o web/landing/www/binaries/hishtory-linux -ldflags "-X main.GitCommit=`git rev-list -1 HEAD`" client/client.go
|
||||||
|
|
||||||
build-static: build-binary
|
build-static: build-binary
|
||||||
docker build -t gcr.io/dworken-k8s/hishtory-static -f web/caddy/Dockerfile .
|
docker build -t gcr.io/dworken-k8s/hishtory-static -f web/caddy/Dockerfile .
|
||||||
|
@ -152,7 +152,7 @@ func export() {
|
|||||||
lib.CheckFatalError(retrieveAdditionalEntriesFromRemote(db))
|
lib.CheckFatalError(retrieveAdditionalEntriesFromRemote(db))
|
||||||
data, err := shared.Search(db, "", 0)
|
data, err := shared.Search(db, "", 0)
|
||||||
lib.CheckFatalError(err)
|
lib.CheckFatalError(err)
|
||||||
for _, entry := range data {
|
for i := len(data)-1; i >= 0; i-- {
|
||||||
fmt.Println(entry)
|
fmt.Println(data[i].Command)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,11 @@ func RunInteractiveBashCommands(t *testing.T, script string) string {
|
|||||||
var err bytes.Buffer
|
var err bytes.Buffer
|
||||||
cmd.Stderr = &err
|
cmd.Stderr = &err
|
||||||
shared.CheckWithInfo(t, cmd.Run(), out.String()+err.String())
|
shared.CheckWithInfo(t, cmd.Run(), out.String()+err.String())
|
||||||
return out.String()
|
outStr := out.String()
|
||||||
|
if strings.Contains(outStr, "hishtory fatal error:") {
|
||||||
|
t.Fatalf("Ran command, but hishtory had a fatal error! out=%#v", outStr)
|
||||||
|
}
|
||||||
|
return outStr
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestIntegration(t *testing.T) {
|
func TestIntegration(t *testing.T) {
|
||||||
@ -150,6 +154,12 @@ func TestIntegrationWithNewDevice(t *testing.T) {
|
|||||||
if !strings.Contains(out, "othercomputer") {
|
if !strings.Contains(out, "othercomputer") {
|
||||||
t.Fatalf("hishtory query doesn't contain cmd run on another machine! out=%#v", out)
|
t.Fatalf("hishtory query doesn't contain cmd run on another machine! out=%#v", out)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Finally, test the export command
|
||||||
|
out = RunInteractiveBashCommands(t, `hishtory export`)
|
||||||
|
if out != fmt.Sprintf("/tmp/client install\n/tmp/client install\nhishtory status\nhishtory query\nhishtory query\nls /a\nls /bar\nls /foo\necho foo\necho bar\nhishtory enable\necho thisisrecorded\nhishtory query\nhishtory query foo\n/tmp/client install %s\nhishtory query\necho mynewcommand\nhishtory query\nhishtory init %s\nhishtory query\necho mynewercommand\nhishtory query\nothercomputer\nhishtory query\n", userSecret, userSecret) {
|
||||||
|
t.Fatalf("hishtory export had unexpected output! out=%#v", out)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func testIntegration(t *testing.T) string {
|
func testIntegration(t *testing.T) string {
|
||||||
@ -233,4 +243,3 @@ func testIntegration(t *testing.T) string {
|
|||||||
return userSecret
|
return userSecret
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(ddworken): Test export
|
|
||||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user