Skip to content

Commit

Permalink
Initial Commit. WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
akasper committed Aug 9, 2024
1 parent 5aec36b commit 1967366
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 0 deletions.
13 changes: 13 additions & 0 deletions spec/Test_Code_suite_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package main_test

import (
"testing"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)

func TestTestCode(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "TestCode Suite")
}
73 changes: 73 additions & 0 deletions spec/test_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package main_test

import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)

type AppConfig struct {
Host string
Port int
Username string
Password string
}

type User struct {
Username string
Password string
Request string
}

var app = AppConfig{
Host: "localhost",
Port: 5432,
Username: "postgres",
Password: "password",
}

var _ = Describe("Reading code systems from the application", func() {
BeforeEach(func() {
FetchApi()
})
Context("GIVEN the service is started", func() {
var appStart *app // Assuming App is a type defined in phinvads
Context("GIVEN the database loads successfully", func() {
BeforeEach(func() {
// Initialize app here if needed
})
Context("GIVEN a valid user with access to the API", func() {
var user *User
BeforeAll(func() {
user = &User{
Username: "testuser",
Password: "testpassword",
}
})
Context("WHEN the user requests all code systems", func() {
user.Request = "/api/code-systems"
It("THEN return a list of all code systems", func() {
Expect(codestystemslist).To(Equal("codestystemslist"))
})
})
Context("WHEN the user requests a specific code system by OID", func() {
user.Request = "/api/code-systems/{oid}"
It("THEN return the desired code system", func() {
Expect(codesystem).To(Equal("codesystem"))
})
})
Context("WHEN the user requests a code system using an INVALID OID", func() {
user.Request = "/api/code-systems/zero"
It("THEN return a 400 error", func() {
Expect(statuscode).To(Equal(400))
})
})
Context("WHEN the user requests a non-existant endpoint", func() {
user.Request = "/api/invalid-endpoint"
It("THEN return a 404 error", func() {
Expect(statuscode).To(Equal(404))
})
})
})
})
})
})

0 comments on commit 1967366

Please sign in to comment.