This repository has been archived by the owner on Feb 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
get_test.go
93 lines (78 loc) · 3.02 KB
/
get_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package main_test
import (
"testing"
"github.com/stealthrocket/timecraft/internal/assert"
)
var get = tests{
"show the get command help with the short option": func(t *testing.T) {
stdout, stderr, exitCode := timecraft(t, "get", "-h")
assert.Equal(t, exitCode, 0)
assert.HasPrefix(t, stdout, "Usage:\ttimecraft get ")
assert.Equal(t, stderr, "")
},
"show the get command help with the long option": func(t *testing.T) {
stdout, stderr, exitCode := timecraft(t, "get", "--help")
assert.Equal(t, exitCode, 0)
assert.HasPrefix(t, stdout, "Usage:\ttimecraft get ")
assert.Equal(t, stderr, "")
},
"get without a resource type": func(t *testing.T) {
stdout, stderr, exitCode := timecraft(t, "get")
assert.Equal(t, exitCode, 2)
assert.Equal(t, stdout, "")
assert.HasPrefix(t, stderr, "Expected at least the resource type as argument")
},
"get configs on an empty time machine": func(t *testing.T) {
stdout, stderr, exitCode := timecraft(t, "get", "configs")
assert.Equal(t, exitCode, 0)
assert.Equal(t, stdout, "CONFIG ID RUNTIME MODULES SIZE\n")
assert.Equal(t, stderr, "")
},
"get modules on an empty time machine": func(t *testing.T) {
stdout, stderr, exitCode := timecraft(t, "get", "modules")
assert.Equal(t, exitCode, 0)
assert.Equal(t, stdout, "MODULE ID MODULE NAME SIZE\n")
assert.Equal(t, stderr, "")
},
"get process on an empty time machine": func(t *testing.T) {
stdout, stderr, exitCode := timecraft(t, "get", "processes")
assert.Equal(t, exitCode, 0)
assert.Equal(t, stdout, "PROCESS ID START SIZE\n")
assert.Equal(t, stderr, "")
},
"get runtimes on an empty time machine": func(t *testing.T) {
stdout, stderr, exitCode := timecraft(t, "get", "runtimes")
assert.Equal(t, exitCode, 0)
assert.Equal(t, stdout, "RUNTIME ID RUNTIME NAME VERSION\n")
assert.Equal(t, stderr, "")
},
"get config after run": func(t *testing.T) {
stdout, processID, exitCode := timecraft(t, "run", "./testdata/go/sleep.wasm", "1ns")
assert.Equal(t, exitCode, 0)
assert.Equal(t, stdout, "sleeping for 1ns\n")
assert.NotEqual(t, processID, "")
configID, stderr, exitCode := timecraft(t, "get", "conf", "-q")
assert.Equal(t, exitCode, 0)
assert.NotEqual(t, configID, "")
assert.Equal(t, stderr, "")
},
"get process after run": func(t *testing.T) {
stdout, processID, exitCode := timecraft(t, "run", "./testdata/go/sleep.wasm", "1ns")
assert.Equal(t, exitCode, 0)
assert.Equal(t, stdout, "sleeping for 1ns\n")
procID, stderr, exitCode := timecraft(t, "get", "proc", "-q")
assert.Equal(t, exitCode, 0)
assert.Equal(t, procID, processID)
assert.Equal(t, stderr, "")
},
"get runtime after run": func(t *testing.T) {
stdout, processID, exitCode := timecraft(t, "run", "./testdata/go/sleep.wasm", "1ns")
assert.Equal(t, exitCode, 0)
assert.Equal(t, stdout, "sleeping for 1ns\n")
assert.NotEqual(t, processID, "")
runtimeID, stderr, exitCode := timecraft(t, "get", "rt", "-q")
assert.Equal(t, exitCode, 0)
assert.NotEqual(t, runtimeID, "")
assert.Equal(t, stderr, "")
},
}