summaryrefslogtreecommitdiff
path: root/jt2.yarn
blob: e3908939db818dd764acae402b2de0bd3b184c89 (plain)
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
---
title: JT acceptance tests v2
author: Lars Wirzenius / The Ick project
...


# Introduction

JT is a command line tool for writing entries in my personal journal.
It works by adding files to the git repository with the journal, for
formatting by the Ikiwiki website compiler. This
document presents its automated acceptance tests, using a (for now
hypothetical) language similar to the Gherkin langauge implemented by
Cucumber.

All of these scenarios start with an empty directory and with JT
configured to put drafts in the `drafts` directory, topics in
`topics`, and finished journal entries in `notes`.

# Happy path scenarios

## Add a journal entry

We start off with an empty journal repository. We only test that it's
empty here; all other scenarios assume this works.

```saga
given an empty journal repository
then there is only .git in the journal repository
```

We create a draft journal entry.

```saga
when I run jt new "my title"
then drafts/0.mdwn exists
and it contains "my title"
```

When we finish the entry, the draft is moved to the notes directory.

```saga
given the date is 2019-09-01
when I run jt finish
then notes/2019/09/01/my_title.mdwn exists
and it contains "my title"
```

## Add a journal entry with an attachment

This is similar to adding a journal entry, except it adds an
attachment to the new entry. The attachment could be anything, such as
a photo.

```saga
given an empty journal repository
when I run jt new "my title"
then drafts/0.mdwn exists
and it contains "my title"
```

The attachment file needs to exist. It gets copied to the drafts
directory.

```saga
given the file photo.jpg exists
when I run jt attach 0 photo.jpg
then drafts/0/photo.jpg exists
```

When we finish the entry, the draft is moved to the notes directory,
with the attachment.

```saga
given the date is 2019-09-01
when I run jt finish
then notes/2019/09/01/my_title.mdwn exists
and it contains "my title"
and notes/2019/09/01/my_title/photo.jpg exists
```


## Add a topic

JT allows "topic", which are meant to be pages that collect entries of
specific topics. The formatted journal will have a page for each topic
shows all entries that reference that topic. Similar to tags, but
another dimension of metadata. It's up to the user to use tags or
topics as they wish.

```saga
given an empty journal repository
when I run jt new-topic 2019/my-project
then topics/2019/my-project.mdwn exists
```

One can add an entry for a topic, but it must exist.

```saga
when I run jt new --topic nonexistent "my title"
then it fails
when I run jt new --topic 2019/my-project "my title"
then drafts/0.mdwn exists
and it contains "2019/my-project"
```

# Unhappy path scenarios

## Finishing when there's more than one draft

JT will pick the draft to act on if there's only one current draft. If
there's more, it will fail with an error message saying "too many
drafts".

```saga
given an empty journal repository
when I run jt new "first"
then drafts/0.mdwn exists
when I run `jt new "second"
then **drafts/1.mdwn_** exists  
when I run `jt finish`  
then it fails with "too many drafts"
```

## Attaching when there's no such draft

Attaching to a draft that doesn't exist doesn't work.

```saga
> given an empty journal repository
> and the file photo.jpg exists
> when I run jt attach 0 photo.jpg
> then it fails with "no such draft"
```

## Attaching when there's no such file

Attaching a file that doesn't exist doesn't work.

```saga
given an empty journal repository
when I run jt new "first"
and I run jt attach 0 photo.jpg
then it fails with "no such file"
```