퀴즈 풀기/점수

This commit is contained in:
2024-02-19 22:43:31 +09:00
parent 41e1ed5c58
commit 05292be591
24 changed files with 2425 additions and 39 deletions

0
test/test.db Normal file
View File

View File

@ -1,6 +1,7 @@
package learsteam_quiz_test
import (
"encoding/json"
"fmt"
config "learnsteam/cslms-api/configs"
"learnsteam/cslms-api/internal/controllers"
@ -10,8 +11,10 @@ import (
"time"
"github.com/golang-jwt/jwt/v5"
"github.com/google/go-cmp/cmp"
"github.com/stretchr/testify/suite"
"github.com/tj/assert"
"gorm.io/datatypes"
"gorm.io/driver/sqlite"
"gorm.io/gorm"
"gorm.io/gorm/schema"
@ -295,3 +298,24 @@ func (suite *TokenTestSuite) TestVerifyExpiredToken() {
assert.Error(suite.T(), err)
assert.False(suite.T(), jwtToken.Valid)
}
func (suite *TokenTestSuite) TestCompareJSON() {
// a := `["a","b","c"]`
// b := `["a","b","c"]`
a := `{"x":1,"y":2}`
b := `{"y":2,"x":1}`
var json1 datatypes.JSON
json1, err := json.Marshal(a)
assert.NoError(suite.T(), err)
var json2 datatypes.JSON
json2, err = json.Marshal(b)
assert.NoError(suite.T(), err)
assert.Equal(suite.T(), json2.String(), "")
compare := cmp.Equal(json1.String(), json2.String())
assert.Equal(suite.T(), true, compare)
}