Skip to content

Commit

Permalink
chore: updated dbml, dependencies and testing
Browse files Browse the repository at this point in the history
  • Loading branch information
rmscoal committed Feb 20, 2024
1 parent 7e7866d commit cc67796
Show file tree
Hide file tree
Showing 9 changed files with 354 additions and 158 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ swagger.yaml
# Log files
logs/log.txt

# Packages
go.sum

# air hot reload
tmp

Expand Down
49 changes: 12 additions & 37 deletions database.dbml
Original file line number Diff line number Diff line change
Expand Up @@ -5,52 +5,27 @@ Docs: https://dbml.dbdiagram.io/docs

table users {
id uuid [pk, default: `gen_random_uuid()`]
first_name varchar(50) [not null]
last_name varchar(50) [not null]
phone_number varchar(25) [not null]
created_at timestamp
updated_at timestamp
deleted_at timestamp

indexes {
deleted_at [type: btree]
phone_number [unique, type: btree]
}
}

table user_emails {
id uuid [pk, default: `gen_random_uuid()`]
user_id uuid [ref: > users.id]
name varchar(150) [not null]
email varchar(50) [not null]
is_primary boolean [default: false]
created_at timestamp
updated_at timestamp
deleted_at timestamp

indexes {
email [unique, type: btree]
}
}

table user_credentials {
id uuid [pk, default: `gen_random_uuid()`]
user_id uuid [ref: - users.id]
username varchar(25) [not null]
username varchar(20) [not null]
phone_number varchar(20) [not null]
password varchar(255) [not null]

created_at timestamp
updated_at timestamp
deleted_at timestamp

indexes {
phone_number [unique, type: btree]
username [unique, type: btree]
email [unique, type: btree]
deleted_at [type: btree]
}
}

table authorization_credentials {
id uuid [pk, default: `gen_random_uuid()`]
version bigint [default: 1]
issued boolean [default: false]
parent_id uuid [ref: - authorization_credentials.id]
user_id uuid [ref: > users.id]
issued_at timestamp [default: `now()`]
table access_versionings {
jti uuid [pk, default: `gen_random_uuid()`]
parent_id uuid [ref: - access_versionings.id, default: null]
user_id uuid [ref: > users.id, not null]
version integer
}
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ require (
github.com/DATA-DOG/go-sqlmock v1.5.2
github.com/go-ozzo/ozzo-validation v3.6.0+incompatible
github.com/golang-jwt/jwt/v5 v5.0.0
github.com/google/uuid v1.3.1
github.com/joho/godotenv v1.5.1
github.com/mitchellh/cli v1.1.5
github.com/swaggo/files v1.0.1
github.com/swaggo/gin-swagger v1.6.0
github.com/swaggo/swag v1.16.2
go.opentelemetry.io/otel v1.21.0
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v0.44.0
Expand Down Expand Up @@ -38,7 +41,6 @@ require (
github.com/go-openapi/spec v0.20.9 // indirect
github.com/go-openapi/swag v0.22.4 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/uuid v1.3.1 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 // indirect
github.com/hashicorp/errwrap v1.0.0 // indirect
github.com/hashicorp/go-multierror v1.0.0 // indirect
Expand All @@ -55,8 +57,6 @@ require (
github.com/shopspring/decimal v1.2.0 // indirect
github.com/spf13/cast v1.3.1 // indirect
github.com/stretchr/objx v0.5.0 // indirect
github.com/swaggo/files v1.0.1 // indirect
github.com/swaggo/gin-swagger v1.6.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.21.0 // indirect
go.opentelemetry.io/proto/otlp v1.0.0 // indirect
golang.org/x/tools v0.16.0 // indirect
Expand Down
303 changes: 303 additions & 0 deletions go.sum

Large diffs are not rendered by default.

14 changes: 0 additions & 14 deletions internal/utils/errors.go

This file was deleted.

34 changes: 0 additions & 34 deletions internal/utils/slices.go

This file was deleted.

67 changes: 0 additions & 67 deletions internal/utils/slices_test.go

This file was deleted.

File renamed without changes.
36 changes: 36 additions & 0 deletions internal/utils/string_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package utils

import (
"fmt"
"testing"

"github.com/stretchr/testify/assert"
)

func TestConvertStringToByteSlice(t *testing.T) {
testcases := []struct {
s string
b []byte
}{
{
s: "",
b: []byte(nil),
},
{
s: "hello world",
b: []byte("hello world"),
},
}

for i, testcase := range testcases {
t.Run(fmt.Sprintf("Running test case %d", i), func(t *testing.T) {
result := ConvertStringToByteSlice(testcase.s)
assert.Equal(t, testcase.b, result)
})
}
}

func TestNewStringPointer(t *testing.T) {
assert.NotNil(t, NewStringPointer("hello"))
assert.NotNil(t, NewStringPointer(""))
}

0 comments on commit cc67796

Please sign in to comment.