()
| 50 | } |
| 51 | |
| 52 | func (s *ObjectStoreTestSuite) SetupTest() { |
| 53 | // create testing sqlite database |
| 54 | dbCfg := garmTesting.GetTestSqliteDBConfig(s.T()) |
| 55 | db, err := database.NewDatabase(context.Background(), dbCfg) |
| 56 | if err != nil { |
| 57 | s.FailNow(fmt.Sprintf("failed to create db connection: %s", err)) |
| 58 | } |
| 59 | |
| 60 | adminCtx := garmTesting.ImpersonateAdminContext(context.Background(), db, s.T()) |
| 61 | |
| 62 | // Create a test file object |
| 63 | testContent := []byte("test file content for object store") |
| 64 | param := params.CreateFileObjectParams{ |
| 65 | Name: "test-file.bin", |
| 66 | Size: int64(len(testContent)), |
| 67 | Tags: []string{"test", "binary"}, |
| 68 | } |
| 69 | fileObj, err := db.CreateFileObject(adminCtx, param, bytes.NewReader(testContent)) |
| 70 | if err != nil { |
| 71 | s.FailNow(fmt.Sprintf("failed to create test file object: %s", err)) |
| 72 | } |
| 73 | |
| 74 | updatedName := "updated-file.txt" |
| 75 | // Setup fixtures |
| 76 | fixtures := &ObjectStoreTestFixtures{ |
| 77 | AdminContext: adminCtx, |
| 78 | UnauthorizedContext: context.Background(), |
| 79 | Store: db, |
| 80 | CreateObjectParams: params.CreateFileObjectParams{ |
| 81 | Name: "new-file.txt", |
| 82 | Size: 100, |
| 83 | Tags: []string{"new", "test"}, |
| 84 | }, |
| 85 | UpdateObjectParams: params.UpdateFileObjectParams{ |
| 86 | Name: &updatedName, |
| 87 | Tags: []string{"updated", "test"}, |
| 88 | }, |
| 89 | TestFileObject: fileObj, |
| 90 | TestFileContent: testContent, |
| 91 | } |
| 92 | s.Fixtures = fixtures |
| 93 | |
| 94 | // Setup test runner |
| 95 | runner := &Runner{ |
| 96 | ctx: fixtures.AdminContext, |
| 97 | store: fixtures.Store, |
| 98 | } |
| 99 | s.Runner = runner |
| 100 | } |
| 101 | |
| 102 | func (s *ObjectStoreTestSuite) TestCreateFileObject() { |
| 103 | content := []byte("new file content") |
nothing calls this directly
no test coverage detected