--- JSON output ---
(t *testing.T)
| 149 | // --- JSON output --- |
| 150 | |
| 151 | func TestWrite_JSON_Password(t *testing.T) { |
| 152 | dir := t.TempDir() |
| 153 | out, err := NewWriter(dir, "json") |
| 154 | require.NoError(t, err) |
| 155 | out.Add("Chrome", "Default", chromeData()) |
| 156 | out.Add("Firefox", "abc123", firefoxData()) |
| 157 | require.NoError(t, out.Write()) |
| 158 | |
| 159 | type pwJSON struct { |
| 160 | Browser string `json:"browser"` |
| 161 | Profile string `json:"profile"` |
| 162 | URL string `json:"url"` |
| 163 | Username string `json:"username"` |
| 164 | Password string `json:"password"` |
| 165 | CreatedAt time.Time `json:"created_at"` |
| 166 | } |
| 167 | var rows []pwJSON |
| 168 | readJSON(t, filepath.Join(dir, "password.json"), &rows) |
| 169 | require.Len(t, rows, 2) |
| 170 | |
| 171 | assert.Equal(t, pwJSON{ |
| 172 | Browser: "Chrome", Profile: "Default", |
| 173 | URL: "https://example.com", Username: "alice", Password: "secret", CreatedAt: testTime, |
| 174 | }, rows[0]) |
| 175 | assert.Equal(t, pwJSON{ |
| 176 | Browser: "Firefox", Profile: "abc123", |
| 177 | URL: "https://reddit.com", Username: "bob", Password: "hunter2", CreatedAt: testTime, |
| 178 | }, rows[1]) |
| 179 | } |
| 180 | |
| 181 | func TestWrite_JSON_Cookie(t *testing.T) { |
| 182 | dir := t.TempDir() |
nothing calls this directly
no test coverage detected