mirror of
https://github.com/ddworken/hishtory.git
synced 2025-06-07 13:46:38 +02:00
fix hardcoded username in tests + another attempt at enabling bash job control + test that building docker containers works
This commit is contained in:
parent
3619bd5447
commit
e9d19eb782
8
.github/workflows/go-test.yml
vendored
8
.github/workflows/go-test.yml
vendored
@ -5,15 +5,15 @@ on:
|
|||||||
branches: [ master ]
|
branches: [ master ]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
test:
|
||||||
build:
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v2
|
uses: actions/setup-go@v2
|
||||||
with:
|
with:
|
||||||
go-version: 1.17
|
go-version: 1.17
|
||||||
- name: Test
|
- name: Go test
|
||||||
run: make test
|
run: make test
|
||||||
|
- name: Build docker contains
|
||||||
|
run: make build-api build-static
|
||||||
|
@ -151,7 +151,7 @@ func TestIntegrationWithNewDevice(t *testing.T) {
|
|||||||
// Finally, test the export command
|
// Finally, test the export command
|
||||||
out = RunInteractiveBashCommands(t, `hishtory export`)
|
out = RunInteractiveBashCommands(t, `hishtory export`)
|
||||||
if out != fmt.Sprintf(
|
if out != fmt.Sprintf(
|
||||||
"/tmp/client install\nset -emo pipefail\nset -emo pipefail\nhishtory status\nset -emo pipefail\nhishtory query\nhishtory query\nls /a\nls /bar\nls /foo\necho foo\necho bar\nhishtory enable\necho thisisrecorded\nset -emo pipefail\nhishtory query\nset -emo pipefail\nhishtory query foo\n/tmp/client install %s\nset -emo pipefail\nhishtory query\nset -emo pipefail\necho mynewcommand\nset -emo pipefail\nhishtory query\nhishtory init %s\nset -emo pipefail\nhishtory query\nset -emo pipefail\necho mynewercommand\nset -emo pipefail\nhishtory query\nothercomputer\nset -emo pipefail\nhishtory query\nset -emo pipefail\n", userSecret, userSecret) {
|
"/tmp/client install\nset -emo pipefail\nset -emo pipefail\nhishtory status\nset -emo pipefail\nhishtory query\nhishtory query\nset -m\nls /a\nls /bar\nls /foo\necho foo\necho bar\nhishtory enable\necho thisisrecorded\nset -emo pipefail\nhishtory query\nset -emo pipefail\nhishtory query foo\n/tmp/client install %s\nset -emo pipefail\nhishtory query\nset -emo pipefail\necho mynewcommand\nset -emo pipefail\nhishtory query\nhishtory init %s\nset -emo pipefail\nhishtory query\nset -emo pipefail\necho mynewercommand\nset -emo pipefail\nhishtory query\nothercomputer\nset -emo pipefail\nhishtory query\nset -emo pipefail\n", userSecret, userSecret) {
|
||||||
t.Fatalf("hishtory export had unexpected output! out=%#v", out)
|
t.Fatalf("hishtory export had unexpected output! out=%#v", out)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -190,6 +190,7 @@ func testIntegration(t *testing.T) string {
|
|||||||
|
|
||||||
// Test recording commands
|
// Test recording commands
|
||||||
out, err := RunInteractiveBashCommandsWithoutStrictMode(t, `
|
out, err := RunInteractiveBashCommandsWithoutStrictMode(t, `
|
||||||
|
set -m
|
||||||
ls /a
|
ls /a
|
||||||
ls /bar
|
ls /bar
|
||||||
ls /foo
|
ls /foo
|
||||||
@ -252,6 +253,7 @@ func TestAdvancedQuery(t *testing.T) {
|
|||||||
|
|
||||||
// Run some commands we can query for
|
// Run some commands we can query for
|
||||||
_, _ = RunInteractiveBashCommandsWithoutStrictMode(t, `
|
_, _ = RunInteractiveBashCommandsWithoutStrictMode(t, `
|
||||||
|
set -m
|
||||||
echo nevershouldappear
|
echo nevershouldappear
|
||||||
notacommand
|
notacommand
|
||||||
cd /tmp/
|
cd /tmp/
|
||||||
|
@ -2,6 +2,7 @@ package lib
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
|
"os/user"
|
||||||
"path"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
@ -39,7 +40,11 @@ func TestBuildHistoryEntry(t *testing.T) {
|
|||||||
if entry.ExitCode != 120 {
|
if entry.ExitCode != 120 {
|
||||||
t.Fatalf("history entry has unexpected exit code: %v", entry.ExitCode)
|
t.Fatalf("history entry has unexpected exit code: %v", entry.ExitCode)
|
||||||
}
|
}
|
||||||
if entry.LocalUsername != "david" {
|
user, err := user.Current()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("failed to retrieve user: %v", err)
|
||||||
|
}
|
||||||
|
if entry.LocalUsername != user.Username {
|
||||||
t.Fatalf("history entry has unexpected user name: %v", entry.LocalUsername)
|
t.Fatalf("history entry has unexpected user name: %v", entry.LocalUsername)
|
||||||
}
|
}
|
||||||
if !strings.HasPrefix(entry.CurrentWorkingDirectory, "/") && !strings.HasPrefix(entry.CurrentWorkingDirectory, "~/") {
|
if !strings.HasPrefix(entry.CurrentWorkingDirectory, "/") && !strings.HasPrefix(entry.CurrentWorkingDirectory, "~/") {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user