Skip to content

Commit 6fa1cf3

Browse files
committed
fix: update ApplicationAddress handling and improve test setup
1 parent 8f5a8dc commit 6fa1cf3

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

pkg/convenience/repository/application_repository.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func (a *ApplicationRepository) Create(ctx context.Context, rawApp *model.Conven
5050
_, err := exec.ExecContext(ctx, insertSql,
5151
rawApp.ID,
5252
rawApp.Name,
53-
rawApp.ApplicationAddress,
53+
rawApp.ApplicationAddress.Hex(),
5454
)
5555

5656
if err != nil {
@@ -73,7 +73,7 @@ func transformToApplicationQuery(filter []*model.ConvenienceFilter) (string, []a
7373
if filter.Eq != nil {
7474
where = append(
7575
where,
76-
fmt.Sprintf("application_address = $%d", count),
76+
fmt.Sprintf("application_address = $%d ", count),
7777
)
7878
args = append(args, *filter.Eq)
7979
count++

pkg/convenience/repository/application_repository_test.go

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,31 @@ type ApplicationRepositorySuite struct {
2222
tempDir string
2323
}
2424

25-
func (s *ApplicationRepositorySuite) SetupTest() {
25+
func (a *ApplicationRepositorySuite) SetupTest() {
2626
commons.ConfigureLog(slog.LevelDebug)
2727

2828
// Temp
2929
tempDir, err := os.MkdirTemp("", "")
30-
s.NoError(err)
31-
s.tempDir = tempDir
30+
a.NoError(err)
31+
a.tempDir = tempDir
3232

3333
// Database
3434
sqliteFileName := filepath.Join(tempDir, "application.sqlite3")
3535

3636
db := sqlx.MustConnect("sqlite3", sqliteFileName)
3737

38-
s.repository = &ApplicationRepository{
38+
a.repository = &ApplicationRepository{
3939
Db: *db,
4040
}
41-
err = s.repository.CreateTables()
42-
s.NoError(err)
41+
err = a.repository.CreateTables()
42+
a.NoError(err)
43+
}
44+
45+
func (a *ApplicationRepositorySuite) TearDownTest() {
46+
err := a.repository.Db.Close()
47+
a.NoError(err)
48+
err = os.RemoveAll(a.tempDir)
49+
a.NoError(err)
4350
}
4451

4552
func TestApplicationRepositorySuite(t *testing.T) {
@@ -72,6 +79,7 @@ func (s *ApplicationRepositorySuite) TestFindApplication() {
7279
for i := 0; i < counter; i++ {
7380
app := newApp()
7481
app.Name = fmt.Sprintf("app%d", i)
82+
app.ApplicationAddress = common.HexToAddress(add)
7583
_, err := s.repository.Create(ctx, app)
7684
s.NoError(err)
7785
}
@@ -87,7 +95,7 @@ func (s *ApplicationRepositorySuite) TestFindApplication() {
8795
s.NoError(err)
8896
s.Equal(counter, int(count))
8997

90-
add = "0xdeadbeef"
98+
add = "0x544a3B76B84b1E98c13437A1591E713Dd314387F"
9199

92100
for i := 0; i < counter; i++ {
93101
app := newApp()

0 commit comments

Comments
 (0)