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

Function TestSetup

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

Source from the content-addressed store, hash-verified

13)
14
15func TestSetup(t *testing.T) {
16 defer testutils.BackupAndRestore(t)()
17 defer testutils.RunTestServer()()
18
19 homedir, err := os.UserHomeDir()
20 require.NoError(t, err)
21 if _, err := os.Stat(path.Join(homedir, data.GetHishtoryPath(), data.CONFIG_PATH)); err == nil {
22 t.Fatalf("hishtory secret file already exists!")
23 }
24 require.NoError(t, setup("", false))
25 if _, err := os.Stat(path.Join(homedir, data.GetHishtoryPath(), data.CONFIG_PATH)); err != nil {
26 t.Fatalf("hishtory secret file does not exist after Setup()!")
27 }
28 data, err := os.ReadFile(path.Join(homedir, data.GetHishtoryPath(), data.CONFIG_PATH))
29 require.NoError(t, err)
30 if len(data) < 10 {
31 t.Fatalf("hishtory secret has unexpected length: %d", len(data))
32 }
33 config := hctx.GetConf(hctx.MakeContext())
34 if config.IsOffline != false {
35 t.Fatalf("hishtory config should have been offline")
36 }
37}
38
39func TestSetupOffline(t *testing.T) {
40 defer testutils.BackupAndRestore(t)()

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