fix hardcoded username in tests + another attempt at enabling bash job control + test that building docker containers works

This commit is contained in:
David Dworken 2022-04-09 12:19:01 -07:00
parent 3619bd5447
commit e9d19eb782
3 changed files with 13 additions and 6 deletions

View File

@ -5,15 +5,15 @@ on:
branches: [ master ]
jobs:
build:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17
- name: Test
- name: Go test
run: make test
- name: Build docker contains
run: make build-api build-static

View File

@ -151,7 +151,7 @@ func TestIntegrationWithNewDevice(t *testing.T) {
// Finally, test the export command
out = RunInteractiveBashCommands(t, `hishtory export`)
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)
}
}
@ -190,6 +190,7 @@ func testIntegration(t *testing.T) string {
// Test recording commands
out, err := RunInteractiveBashCommandsWithoutStrictMode(t, `
set -m
ls /a
ls /bar
ls /foo
@ -252,6 +253,7 @@ func TestAdvancedQuery(t *testing.T) {
// Run some commands we can query for
_, _ = RunInteractiveBashCommandsWithoutStrictMode(t, `
set -m
echo nevershouldappear
notacommand
cd /tmp/

View File

@ -2,6 +2,7 @@ package lib
import (
"os"
"os/user"
"path"
"strings"
"testing"
@ -39,7 +40,11 @@ func TestBuildHistoryEntry(t *testing.T) {
if entry.ExitCode != 120 {
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)
}
if !strings.HasPrefix(entry.CurrentWorkingDirectory, "/") && !strings.HasPrefix(entry.CurrentWorkingDirectory, "~/") {