fix: tests + version

- Update code as per go 1.19.3
- Fix tests for unused vars
This commit is contained in:
Lakhan Samani
2022-11-27 20:40:45 +05:30
parent a366b2811d
commit 91d17a9b1f
31 changed files with 542 additions and 97 deletions

View File

@@ -1,6 +1,7 @@
package models
import (
"encoding/json"
"strings"
"github.com/authorizerdev/authorizer/server/graph/model"
@@ -35,3 +36,10 @@ func (e *EmailTemplate) AsAPIEmailTemplate() *model.EmailTemplate {
UpdatedAt: refs.NewInt64Ref(e.UpdatedAt),
}
}
func (e *EmailTemplate) ToMap() map[string]interface{} {
res := map[string]interface{}{}
data, _ := json.Marshal(e) // Convert to a json string
json.Unmarshal(data, &res) // Convert to a map
return res
}

View File

@@ -1,5 +1,7 @@
package models
import "encoding/json"
// Note: any change here should be reflected in providers/casandra/provider.go as it does not have model support in collection creation
// Env model for db
@@ -11,3 +13,10 @@ type Env struct {
UpdatedAt int64 `json:"updated_at" bson:"updated_at" cql:"updated_at" dynamo:"updated_at"`
CreatedAt int64 `json:"created_at" bson:"created_at" cql:"created_at" dynamo:"created_at"`
}
func (env *Env) ToMap() map[string]interface{} {
res := map[string]interface{}{}
data, _ := json.Marshal(env) // Convert to a json string
json.Unmarshal(data, &res) // Convert to a map
return res
}

View File

@@ -13,6 +13,10 @@ type CollectionList struct {
}
var (
// DB/Namespace
DBNamespace = "authorizer"
// Identifier field used for surreal db
SurrealDbIdentifier = "identifier"
// Prefix for table name / collection names
Prefix = "authorizer_"
// Collections / Tables available for authorizer in the database (used for dbs other than gorm)

View File

@@ -1,5 +1,7 @@
package models
import "encoding/json"
// OTP model for database
type OTP struct {
Key string `json:"_key,omitempty" bson:"_key,omitempty" cql:"_key,omitempty" dynamo:"key,omitempty"` // for arangodb
@@ -14,3 +16,10 @@ type OTP struct {
type Paging struct {
ID string `json:"id,omitempty" dynamo:"id,hash"`
}
func (o *OTP) ToMap() map[string]interface{} {
res := map[string]interface{}{}
data, _ := json.Marshal(o) // Convert to a json string
json.Unmarshal(data, &res) // Convert to a map
return res
}

View File

@@ -1,5 +1,7 @@
package models
import "encoding/json"
// Note: any change here should be reflected in providers/casandra/provider.go as it does not have model support in collection creation
// Session model for db
@@ -12,3 +14,10 @@ type Session struct {
CreatedAt int64 `json:"created_at" bson:"created_at" cql:"created_at" dynamo:"created_at"`
UpdatedAt int64 `json:"updated_at" bson:"updated_at" cql:"updated_at" dynamo:"updated_at"`
}
func (s *Session) ToMap() map[string]interface{} {
res := map[string]interface{}{}
data, _ := json.Marshal(s) // Convert to a json string
json.Unmarshal(data, &res) // Convert to a map
return res
}

View File

@@ -1,6 +1,7 @@
package models
import (
"encoding/json"
"strings"
"github.com/authorizerdev/authorizer/server/graph/model"
@@ -41,3 +42,10 @@ func (v *VerificationRequest) AsAPIVerificationRequest() *model.VerificationRequ
UpdatedAt: refs.NewInt64Ref(v.UpdatedAt),
}
}
func (v *VerificationRequest) ToMap() map[string]interface{} {
res := map[string]interface{}{}
data, _ := json.Marshal(v) // Convert to a json string
json.Unmarshal(data, &res) // Convert to a map
return res
}

View File

@@ -42,3 +42,10 @@ func (w *Webhook) AsAPIWebhook() *model.Webhook {
UpdatedAt: refs.NewInt64Ref(w.UpdatedAt),
}
}
func (w *Webhook) ToMap() map[string]interface{} {
res := map[string]interface{}{}
data, _ := json.Marshal(w) // Convert to a json string
json.Unmarshal(data, &res) // Convert to a map
return res
}

View File

@@ -1,6 +1,7 @@
package models
import (
"encoding/json"
"strings"
"github.com/authorizerdev/authorizer/server/graph/model"
@@ -37,3 +38,10 @@ func (w *WebhookLog) AsAPIWebhookLog() *model.WebhookLog {
UpdatedAt: refs.NewInt64Ref(w.UpdatedAt),
}
}
func (w *WebhookLog) ToMap() map[string]interface{} {
res := map[string]interface{}{}
data, _ := json.Marshal(w) // Convert to a json string
json.Unmarshal(data, &res) // Convert to a map
return res
}