@@ -8,14 +8,16 @@ import (
88 "github.com/stretchr/testify/assert"
99)
1010
11+ const testDeveloperAppAddress = "0x7d7b6b7a97d1deefe3a1ccc5a13c48e8f055e0b6"
12+
1113func TestGetDeveloperAppsQueries (t * testing.T ) {
1214 app := testAppWithFixtures (t )
1315 developerApps , err := app .queries .GetDeveloperApps (t .Context (), dbv1.GetDeveloperAppsParams {
1416 UserID : 1 ,
1517 })
1618 assert .NoError (t , err )
1719 assert .Len (t , developerApps , 1 )
18- assert .Equal (t , "0x7d7b6b7a97d1deefe3a1ccc5a13c48e8f055e0b6" , developerApps [0 ].Address )
20+ assert .Equal (t , testDeveloperAppAddress , developerApps [0 ].Address )
1921 // redirect_uris must be an empty slice (not nil) when no URIs are registered
2022 assert .Equal (t , []string {}, developerApps [0 ].RedirectUris )
2123}
@@ -26,11 +28,83 @@ func TestGetDeveloperApp(t *testing.T) {
2628 var resp struct {
2729 Data dbv1.GetDeveloperAppsRow
2830 }
29- status , body := testGet (t , app , "/v1/developer_apps/0x7d7b6b7a97d1deefe3a1ccc5a13c48e8f055e0b6" , & resp )
31+ status , body := testGet (t , app , "/v1/developer_apps/" + testDeveloperAppAddress , & resp )
3032 assert .Equal (t , 200 , status )
3133 assert .True (t , strings .Contains (string (body ), `"user_id":"7eP5n"` ))
3234 assert .True (t , strings .Contains (string (body ), `"name":"cool app"` ))
3335 assert .Equal (t , "cool app" , resp .Data .Name )
3436 // redirect_uris must be an empty slice (not nil) when no URIs are registered
3537 assert .Equal (t , []string {}, resp .Data .RedirectUris )
3638}
39+
40+ func TestGetDeveloperAppUppercaseAddress (t * testing.T ) {
41+ app := testAppWithFixtures (t )
42+
43+ var resp struct {
44+ Data dbv1.GetDeveloperAppsRow
45+ }
46+ // Uppercase address should still find the app (case-insensitive lookup)
47+ status , _ := testGet (t , app , "/v1/developer_apps/0x7D7B6B7A97D1DEEFE3A1CCC5A13C48E8F055E0B6" , & resp )
48+ assert .Equal (t , 200 , status )
49+ assert .Equal (t , "cool app" , resp .Data .Name )
50+ }
51+
52+ func TestGetDeveloperAppMixedCaseAddress (t * testing.T ) {
53+ app := testAppWithFixtures (t )
54+
55+ var resp struct {
56+ Data dbv1.GetDeveloperAppsRow
57+ }
58+ // Mixed-case address should still find the app (case-insensitive lookup)
59+ status , _ := testGet (t , app , "/v1/developer_apps/0x7d7B6B7A97d1deEFe3A1ccc5A13c48E8F055e0B6" , & resp )
60+ assert .Equal (t , 200 , status )
61+ assert .Equal (t , "cool app" , resp .Data .Name )
62+ }
63+
64+ func TestGetDeveloperAppWithoutHexPrefix (t * testing.T ) {
65+ app := testAppWithFixtures (t )
66+
67+ var resp struct {
68+ Data dbv1.GetDeveloperAppsRow
69+ }
70+ // Address without 0x prefix should still find the app
71+ status , _ := testGet (t , app , "/v1/developer_apps/7D7B6B7A97D1DEEFE3A1CCC5A13C48E8F055E0B6" , & resp )
72+ assert .Equal (t , 200 , status )
73+ assert .Equal (t , "cool app" , resp .Data .Name )
74+ }
75+
76+ func TestGetDeveloperAppUppercaseAddress (t * testing.T ) {
77+ app := testAppWithFixtures (t )
78+
79+ var resp struct {
80+ Data dbv1.GetDeveloperAppsRow
81+ }
82+ // Uppercase address should still find the app (case-insensitive lookup)
83+ status , _ := testGet (t , app , "/v1/developer_apps/0x7D7B6B7A97D1DEEFE3A1CCC5A13C48E8F055E0B6" , & resp )
84+ assert .Equal (t , 200 , status )
85+ assert .Equal (t , "cool app" , resp .Data .Name )
86+ }
87+
88+ func TestGetDeveloperAppMixedCaseAddress (t * testing.T ) {
89+ app := testAppWithFixtures (t )
90+
91+ var resp struct {
92+ Data dbv1.GetDeveloperAppsRow
93+ }
94+ // Mixed-case address should still find the app (case-insensitive lookup)
95+ status , _ := testGet (t , app , "/v1/developer_apps/0x7d7B6B7A97d1deEFe3A1ccc5A13c48E8F055e0B6" , & resp )
96+ assert .Equal (t , 200 , status )
97+ assert .Equal (t , "cool app" , resp .Data .Name )
98+ }
99+
100+ func TestGetDeveloperAppWithoutHexPrefix (t * testing.T ) {
101+ app := testAppWithFixtures (t )
102+
103+ var resp struct {
104+ Data dbv1.GetDeveloperAppsRow
105+ }
106+ // Address without 0x prefix should still find the app
107+ status , _ := testGet (t , app , "/v1/developer_apps/7D7B6B7A97D1DEEFE3A1CCC5A13C48E8F055E0B6" , & resp )
108+ assert .Equal (t , 200 , status )
109+ assert .Equal (t , "cool app" , resp .Data .Name )
110+ }
0 commit comments