Download this file
| 1 | package chat |
| 2 | |
| 3 | import ( |
| 4 | "strings" |
| 5 | "testing" |
| 6 | ) |
| 7 | |
| 8 | // The kept session id a runner reports is stored only as a plain id: a |
| 9 | // Claude UUID, a Pi or OpenCode session id; anything else (a path, a |
| 10 | // line, something long) is no session. |
| 11 | func TestKeptSessionID(t *testing.T) { |
| 12 | for in, want := range map[string]string{ |
| 13 | "292f17ae-3f37-428e-b63e-8c7f9d178237": "292f17ae-3f37-428e-b63e-8c7f9d178237", |
| 14 | "ses_0123456789abcdef": "ses_0123456789abcdef", |
| 15 | "": "", |
| 16 | "../../etc/passwd": "", |
| 17 | "a b": "", |
| 18 | "id\nnext": "", |
| 19 | strings.Repeat("a", 129): "", |
| 20 | strings.Repeat("a", 128): strings.Repeat("a", 128), |
| 21 | } { |
| 22 | if got := keptSessionID(in); got != want { |
| 23 | t.Errorf("keptSessionID(%q) = %q, want %q", in, got, want) |
| 24 | } |
| 25 | } |
| 26 | } |
| 27 | |