MCPcopy
hub / github.com/ddworken/hishtory / TestSetupOffline

Function TestSetupOffline

client/cmd/install_test.go:39–61  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

37}
38
39func TestSetupOffline(t *testing.T) {
40 defer testutils.BackupAndRestore(t)()
41 defer testutils.RunTestServer()()
42
43 homedir, err := os.UserHomeDir()
44 require.NoError(t, err)
45 if _, err := os.Stat(path.Join(homedir, data.GetHishtoryPath(), data.CONFIG_PATH)); err == nil {
46 t.Fatalf("hishtory secret file already exists!")
47 }
48 require.NoError(t, setup("", true))
49 if _, err := os.Stat(path.Join(homedir, data.GetHishtoryPath(), data.CONFIG_PATH)); err != nil {
50 t.Fatalf("hishtory secret file does not exist after Setup()!")
51 }
52 data, err := os.ReadFile(path.Join(homedir, data.GetHishtoryPath(), data.CONFIG_PATH))
53 require.NoError(t, err)
54 if len(data) < 10 {
55 t.Fatalf("hishtory secret has unexpected length: %d", len(data))
56 }
57 config := hctx.GetConf(hctx.MakeContext())
58 if config.IsOffline != true {
59 t.Fatalf("hishtory config should have been offline, actual=%#v", string(data))
60 }
61}

Callers

nothing calls this directly

Calls 6

BackupAndRestoreFunction · 0.92
RunTestServerFunction · 0.92
GetHishtoryPathFunction · 0.92
GetConfFunction · 0.92
MakeContextFunction · 0.92
setupFunction · 0.85

Tested by

no test coverage detected