Skip to content

Commit

Permalink
[internal/database] add test for GetCorrID with bad input
Browse files Browse the repository at this point in the history
This ads a missing test case where the user/filepath doesn't have any match in the DB
  • Loading branch information
jbygdell committed Dec 30, 2024
1 parent d56a34b commit 591ecea
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions sda/internal/database/db_functions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,23 @@ func (suite *DatabaseTests) TestGetCorrID_sameFilePath() {

}

func (suite *DatabaseTests) TestGetCorrID_wrongFilePath() {
db, err := NewSDAdb(suite.dbConf)
assert.NoError(suite.T(), err, "got (%v) when creating new connection", err)

filePath := "/testuser/file10.c4gh"
user := "testuser"

fileID, err := db.RegisterFile(filePath, user)
assert.NoError(suite.T(), err, "failed to register file in database")
err = db.UpdateFileEventLog(fileID, "uploaded", fileID, user, "{}", "{}")
assert.NoError(suite.T(), err, "failed to update satus of file in database")

corrID, err := db.GetCorrID(user, "/testuser/file20.c4gh", "")
assert.EqualError(suite.T(), err, "sql: no rows in result set")
assert.Equal(suite.T(), "", corrID)
}

func (suite *DatabaseTests) TestGetCorrID_fileWithAccessionID() {
db, err := NewSDAdb(suite.dbConf)
assert.NoError(suite.T(), err, "got (%v) when creating new connection", err)
Expand Down

0 comments on commit 591ecea

Please sign in to comment.