refactor: Update ARR body parsing logic

This commit is contained in:
windyboy
2024-07-23 11:29:12 +08:00
parent 3202521f7b
commit 77a7c7eae0
14 changed files with 3348 additions and 50 deletions
+50 -2
View File
@@ -2,9 +2,11 @@ package repository
import (
"caatsm/internal/domain"
"context"
"testing"
"time"
"github.com/hasura/go-graphql-client"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
@@ -15,6 +17,52 @@ func TestConfig(t *testing.T) {
}
var _ = Describe("Repositories", func() {
Context("Just a simple test", func() {
// Define a struct for the mutation input to match the expected GraphQL input
// Define a struct for the mutation input to match the expected GraphQL input
type aviation_user_insert_input struct {
Name graphql.String `json:"name"`
Email graphql.String `json:"email"`
UpdateAt graphql.String `json:"update_at"` // Use string for timestamp
}
// Get the current time in RFC3339 format
currentTime := time.Now().Format(time.RFC3339)
input := aviation_user_insert_input{
Name: graphql.String("new"),
Email: graphql.String("2@2.com"),
UpdateAt: graphql.String(currentTime), // Use formatted string
}
// Define the mutation
var mutation struct {
InsertAviationUserOne struct {
ID int `json:"id"`
Name string
} `graphql:"insert_aviation_user_one(object: $object)"`
}
// Define the mutation variables
// Define the mutation variables
variables := map[string]interface{}{
"object": input,
}
// Define the mutation
client := graphql.NewClient("http://localhost:8080/v1/graphql", nil)
err := client.Mutate(context.Background(), &mutation, variables)
It("should not error", func() {
Expect(err).NotTo(HaveOccurred())
})
It("name should be new", func() {
Expect(mutation.InsertAviationUserOne.Name).To(Equal("new"))
})
})
Context("Hasura Repository", func() {
// var repository *HasuraRepository
var uuid = "uuid"
@@ -34,8 +82,8 @@ var _ = Describe("Repositories", func() {
OriginatorDateTime: "originator_date_time",
Category: "category",
BodyAndFooter: "body_and_footer",
BodyData: nil,
ReceivedAt: time.Now(),
// BodyData: &interface{},
ReceivedAt: time.Now(),
}
err := repository.InsertParsedMessage(parseMessage)
Expect(err).NotTo(HaveOccurred())