| 1 | package session |
| 2 | |
| 3 | import ( |
| 4 | "path/filepath" |
| 5 | "testing" |
| 6 | ) |
| 7 | |
| 8 | func TestQueryStatReturnsHeaderBackedIdentityWithoutReadingHistory(t *testing.T) { |
| 9 | service, err := NewService("local", NewFilesystemPersistence(t.TempDir())) |
| 10 | if err != nil { |
| 11 | t.Fatal(err) |
| 12 | } |
| 13 | t.Cleanup(func() { _ = service.Shutdown(t.Context()) }) |
| 14 | runtime, err := service.Create(t.Context(), CreateOptions{ |
| 15 | SessionID: "header-stat", CWD: "/workspace", Origin: SessionOriginNew, |
| 16 | }) |
| 17 | if err != nil { |
| 18 | t.Fatal(err) |
| 19 | } |
| 20 | |
| 21 | info, err := service.Query().Stat(t.Context(), runtime.Ref()) |
| 22 | if err != nil { |
| 23 | t.Fatal(err) |
| 24 | } |
| 25 | // Headers record CWD in OS-native form, so the expectation is cleaned the |
| 26 | // same way the writer cleans it instead of assuming POSIX separators. |
| 27 | if info.Ref != runtime.Ref() || info.CWD != filepath.Clean("/workspace") || info.Origin != SessionOriginNew { |
| 28 | t.Fatalf("stat = %#v", info) |
| 29 | } |
| 30 | } |
| 31 |