This repository was 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
Expand file tree
/
Copy pathlogs_test.go
More file actions
42 lines (35 loc) · 1.51 KB
/
logs_test.go
File metadata and controls
42 lines (35 loc) · 1.51 KB
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
package main_test
import (
"strings"
"testing"
"github.com/stealthrocket/timecraft/internal/assert"
)
const text = `
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.`
var logs = tests{
"show the logs command help with the short option": func(t *testing.T) {
stdout, stderr, exitCode := timecraft(t, "logs", "-h")
assert.Equal(t, exitCode, 0)
assert.HasPrefix(t, stdout, "Usage:\ttimecraft logs ")
assert.Equal(t, stderr, "")
},
"show the logs command help with the long option": func(t *testing.T) {
stdout, stderr, exitCode := timecraft(t, "logs", "--help")
assert.Equal(t, exitCode, 0)
assert.HasPrefix(t, stdout, "Usage:\ttimecraft logs ")
assert.Equal(t, stderr, "")
},
"the output of a run is available when printing its logs": func(t *testing.T) {
stdout, stderr, exitCode := timecraft(t, "run", "./testdata/go/echo.wasm", "-n", text)
assert.Equal(t, exitCode, 0)
assert.Equal(t, stdout, text[1:])
processID := strings.TrimSpace(stderr)
stdout, stderr, exitCode = timecraft(t, "logs", processID)
assert.Equal(t, exitCode, 0)
assert.Equal(t, stdout, text[1:])
assert.Equal(t, stderr, "")
},
}