From 6044b00065fd9d3f6429bddbc8a2126986c3f73c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Schr=C3=B6ter?= Date: Fri, 7 Feb 2025 16:41:17 +0100 Subject: [PATCH] fix tests --- paperless_test.go | 27 +----------------------- types.go | 54 ++++++++++++++++++++++++----------------------- 2 files changed, 29 insertions(+), 52 deletions(-) diff --git a/paperless_test.go b/paperless_test.go index 30b10a0..482a825 100644 --- a/paperless_test.go +++ b/paperless_test.go @@ -9,7 +9,6 @@ import ( "net/http/httptest" "os" "testing" - "time" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -180,31 +179,7 @@ func TestGetDocumentsByTags(t *testing.T) { // Mock data for documents documentsResponse := GetDocumentsApiResponse{ - Results: []struct { - ID int `json:"id"` - Correspondent int `json:"correspondent"` - DocumentType interface{} `json:"document_type"` - StoragePath interface{} `json:"storage_path"` - Title string `json:"title"` - Content string `json:"content"` - Tags []int `json:"tags"` - Created time.Time `json:"created"` - CreatedDate string `json:"created_date"` - Modified time.Time `json:"modified"` - Added time.Time `json:"added"` - ArchiveSerialNumber interface{} `json:"archive_serial_number"` - OriginalFileName string `json:"original_file_name"` - ArchivedFileName string `json:"archived_file_name"` - Owner int `json:"owner"` - UserCanChange bool `json:"user_can_change"` - Notes []interface{} `json:"notes"` - SearchHit struct { - Score float64 `json:"score"` - Highlights string `json:"highlights"` - NoteHighlights string `json:"note_highlights"` - Rank int `json:"rank"` - } `json:"__search_hit__"` - }{ + Results: []GetDocumentApiResponseResult{ { ID: 1, Title: "Document 1", diff --git a/types.go b/types.go index 635f109..6a86b58 100644 --- a/types.go +++ b/types.go @@ -1,37 +1,39 @@ package main +type GetDocumentApiResponseResult struct { + ID int `json:"id"` + Correspondent int `json:"correspondent"` + // DocumentType interface{} `json:"document_type"` + // StoragePath interface{} `json:"storage_path"` + Title string `json:"title"` + Content string `json:"content"` + Tags []int `json:"tags"` + // Created time.Time `json:"created"` + // CreatedDate string `json:"created_date"` + // Modified time.Time `json:"modified"` + // Added time.Time `json:"added"` + // ArchiveSerialNumber interface{} `json:"archive_serial_number"` + // OriginalFileName string `json:"original_file_name"` + // ArchivedFileName string `json:"archived_file_name"` + // Owner int `json:"owner"` + // UserCanChange bool `json:"user_can_change"` + Notes []interface{} `json:"notes"` + // SearchHit struct { + // Score float64 `json:"score"` + // Highlights string `json:"highlights"` + // NoteHighlights string `json:"note_highlights"` + // Rank int `json:"rank"` + // } `json:"__search_hit__"` +} + // GetTagsApiResponse is the response payload for /tags endpoint. // But we are only interested in a subset of the fields. type GetDocumentsApiResponse struct { Count int `json:"count"` // Next interface{} `json:"next"` // Previous interface{} `json:"previous"` - All []int `json:"all"` - Results []struct { - ID int `json:"id"` - Correspondent int `json:"correspondent"` - // DocumentType interface{} `json:"document_type"` - // StoragePath interface{} `json:"storage_path"` - Title string `json:"title"` - Content string `json:"content"` - Tags []int `json:"tags"` - // Created time.Time `json:"created"` - // CreatedDate string `json:"created_date"` - // Modified time.Time `json:"modified"` - // Added time.Time `json:"added"` - // ArchiveSerialNumber interface{} `json:"archive_serial_number"` - // OriginalFileName string `json:"original_file_name"` - // ArchivedFileName string `json:"archived_file_name"` - // Owner int `json:"owner"` - // UserCanChange bool `json:"user_can_change"` - Notes []interface{} `json:"notes"` - // SearchHit struct { - // Score float64 `json:"score"` - // Highlights string `json:"highlights"` - // NoteHighlights string `json:"note_highlights"` - // Rank int `json:"rank"` - // } `json:"__search_hit__"` - } `json:"results"` + All []int `json:"all"` + Results []GetDocumentApiResponseResult `json:"results"` } // GetDocumentApiResponse is the response payload for /documents/{id} endpoint.