]> git.giacomolli.uk - onechat/blobdiff - tools_test.go
Name subtests for the behavior they prove
[onechat] / tools_test.go
index e1b19bbb05a125026654985d4240aabf37aac52b..fbbea411779bccb2435a7c5ccf7d0a339e47bc37 100644 (file)
@@ -29,6 +29,7 @@ func TestToolRunsAfterItsCallIsDurable(t *testing.T) {
                "flush, marker absent",
                "echo: done\n",
        }, log.Events())
                "flush, marker absent",
                "echo: done\n",
        }, log.Events())
+
        require.FileExists(t, filepath.Join(dir, "ran"))
 }
 
        require.FileExists(t, filepath.Join(dir, "ran"))
 }
 
@@ -58,22 +59,22 @@ func TestShellRunsInTheWorkingDirectory(t *testing.T) {
                output  string
        }{
                {
                output  string
        }{
                {
-                       name:    "working directory",
+                       name:    "runs in the configured working directory",
                        command: "pwd",
                        output:  dir + "\n",
                },
                {
                        command: "pwd",
                        output:  dir + "\n",
                },
                {
-                       name:    "error output and exit status",
+                       name:    "returns both streams and the failed exit status",
                        command: "echo out; echo err >&2; exit 3",
                        output:  "out\nerr\n\n[exit status 3]",
                },
                {
                        command: "echo out; echo err >&2; exit 3",
                        output:  "out\nerr\n\n[exit status 3]",
                },
                {
-                       name:    "no output",
+                       name:    "marks an empty successful output",
                        command: "true",
                        output:  "(no output)",
                },
                {
                        command: "true",
                        output:  "(no output)",
                },
                {
-                       name:    "no input",
+                       name:    "closes standard input without user input",
                        command: "cat",
                        output:  "(no output)",
                },
                        command: "cat",
                        output:  "(no output)",
                },
@@ -139,7 +140,7 @@ func TestZoomAndDateReadTheChat(t *testing.T) {
                output    string
        }{
                {
                output    string
        }{
                {
-                       name:      "one message whole",
+                       name:      "returns one message without shortening it",
                        arguments: `{"id":2,"n":1}`,
                        output:    "user: two",
                },
                        arguments: `{"id":2,"n":1}`,
                        output:    "user: two",
                },
@@ -149,12 +150,12 @@ func TestZoomAndDateReadTheChat(t *testing.T) {
                        output:    "0+2|user: zero user: one\n2+2|user: two user: three",
                },
                {
                        output:    "0+2|user: zero user: one\n2+2|user: two user: three",
                },
                {
-                       name:      "an id that is not a multiple of n",
+                       name:      "rejects an unaligned line ID",
                        arguments: `{"id":1,"n":2}`,
                        output:    "error: line 1+2 does not exist: n must be a power of 2 and id a multiple of n",
                },
                {
                        arguments: `{"id":1,"n":2}`,
                        output:    "error: line 1+2 does not exist: n must be a power of 2 and id a multiple of n",
                },
                {
-                       name:      "a line past the last message",
+                       name:      "rejects a line beyond the chat",
                        arguments: `{"id":4,"n":4}`,
                        output:    "error: line 4+4 goes past the last message, 3",
                },
                        arguments: `{"id":4,"n":4}`,
                        output:    "error: line 4+4 goes past the last message, 3",
                },