2024-07-22 18:00:51 +08:00
|
|
|
package repository
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"caatsm/internal/domain"
|
|
|
|
|
"testing"
|
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
. "github.com/onsi/ginkgo/v2"
|
|
|
|
|
. "github.com/onsi/gomega"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestConfig(t *testing.T) {
|
|
|
|
|
RegisterFailHandler(Fail)
|
|
|
|
|
RunSpecs(t, "Repositories Suite")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var _ = Describe("Repositories", func() {
|
2024-07-23 12:01:58 +08:00
|
|
|
// Context("Just a simple test", func() {
|
2024-07-23 11:29:12 +08:00
|
|
|
|
2024-07-23 12:01:58 +08:00
|
|
|
// // 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)
|
2024-07-23 11:29:12 +08:00
|
|
|
|
2024-07-23 12:01:58 +08:00
|
|
|
// input := aviation_user_insert_input{
|
|
|
|
|
// Name: graphql.String("new"),
|
|
|
|
|
// Email: graphql.String("2@2.com"),
|
|
|
|
|
// UpdateAt: graphql.String(currentTime), // Use formatted string
|
|
|
|
|
// }
|
2024-07-23 11:29:12 +08:00
|
|
|
|
2024-07-23 12:01:58 +08:00
|
|
|
// // Define the mutation
|
|
|
|
|
// var mutation struct {
|
|
|
|
|
// InsertAviationUserOne struct {
|
|
|
|
|
// ID int `json:"id"`
|
|
|
|
|
// Name string
|
|
|
|
|
// } `graphql:"insert_aviation_user_one(object: $object)"`
|
|
|
|
|
// }
|
2024-07-23 11:29:12 +08:00
|
|
|
|
2024-07-23 12:01:58 +08:00
|
|
|
// // Define the mutation variables
|
|
|
|
|
// // Define the mutation variables
|
|
|
|
|
// variables := map[string]interface{}{
|
|
|
|
|
// "object": input,
|
|
|
|
|
// }
|
|
|
|
|
// // Define the mutation
|
2024-07-23 11:29:12 +08:00
|
|
|
|
2024-07-23 12:01:58 +08:00
|
|
|
// client := graphql.NewClient("http://localhost:8080/v1/graphql", nil)
|
2024-07-23 11:29:12 +08:00
|
|
|
|
2024-07-23 12:01:58 +08:00
|
|
|
// err := client.Mutate(context.Background(), &mutation, variables)
|
|
|
|
|
// It("should not error", func() {
|
|
|
|
|
// Expect(err).NotTo(HaveOccurred())
|
|
|
|
|
// })
|
2024-07-23 11:29:12 +08:00
|
|
|
|
2024-07-23 12:01:58 +08:00
|
|
|
// It("name should be new", func() {
|
|
|
|
|
// Expect(mutation.InsertAviationUserOne.Name).To(Equal("new"))
|
|
|
|
|
// })
|
2024-07-23 11:29:12 +08:00
|
|
|
|
2024-07-23 12:01:58 +08:00
|
|
|
// })
|
2024-07-23 11:29:12 +08:00
|
|
|
|
2024-07-22 18:00:51 +08:00
|
|
|
Context("Hasura Repository", func() {
|
|
|
|
|
// var repository *HasuraRepository
|
|
|
|
|
var uuid = "uuid"
|
|
|
|
|
// BeforeEach(func() {
|
|
|
|
|
|
|
|
|
|
// })
|
|
|
|
|
It("should mutate a parsed message", func() {
|
|
|
|
|
repository := NewHasuraRepo("http://localhost:8080/v1/graphql", "aviation-test")
|
|
|
|
|
parseMessage := &domain.ParsedMessage{
|
|
|
|
|
Uuid: uuid,
|
|
|
|
|
MessageID: "message_id",
|
|
|
|
|
DateTime: "date_time",
|
|
|
|
|
PriorityIndicator: "priority_indicator",
|
|
|
|
|
PrimaryAddress: "primary_address",
|
|
|
|
|
SecondaryAddresses: []string{"secondary_addresses"},
|
|
|
|
|
Originator: "originator",
|
|
|
|
|
OriginatorDateTime: "originator_date_time",
|
|
|
|
|
Category: "category",
|
|
|
|
|
BodyAndFooter: "body_and_footer",
|
2024-07-23 12:01:58 +08:00
|
|
|
BodyData: domain.ARR{AircraftID: "aircraft_id", Category: "ARR", DepartureAirport: "departure_airport", DepartureTime: "departure_time", ArrivalAirport: "arrival_airport", ArrivalTime: "arrival_time"},
|
|
|
|
|
ReceivedAt: time.Now(),
|
2024-07-22 18:00:51 +08:00
|
|
|
}
|
|
|
|
|
err := repository.InsertParsedMessage(parseMessage)
|
|
|
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
})
|