new endpoints

This commit is contained in:
samantha42
2026-03-21 16:49:01 +01:00
parent 3490dd13d4
commit c55e7d6774
5 changed files with 213 additions and 68 deletions

View File

@@ -50,7 +50,7 @@ func TestCreateDepartment_OK(t *testing.T) {
testutil.AssertStatus(t, w, http.StatusCreated)
var got database.Department
var got model.Department
testutil.DecodeJSON(t, w, &got)
if got.Code != "ENG" {
t.Errorf("code: got %q, want %q", got.Code, "ENG")
@@ -72,7 +72,7 @@ func TestCreateDepartment_DefaultsActiveTrue(t *testing.T) {
testutil.AssertStatus(t, w, http.StatusCreated)
var got database.Department
var got model.Department
testutil.DecodeJSON(t, w, &got)
if !got.Active {
t.Error("expected active to default to true when omitted")
@@ -116,7 +116,7 @@ func TestCreateDepartment_Upsert(t *testing.T) {
w := testutil.Do(t, fn, http.MethodPost, "/", map[string]any{"code": "FIN", "name": "Finance Updated"})
testutil.AssertStatus(t, w, http.StatusCreated)
var got database.Department
var got model.Department
testutil.DecodeJSON(t, w, &got)
if got.Name != "Finance Updated" {
t.Errorf("upsert name: got %q, want %q", got.Name, "Finance Updated")
@@ -131,7 +131,7 @@ func TestListDepartments_Empty(t *testing.T) {
w := testutil.Do(t, http.HandlerFunc(h.ListDepartments), http.MethodGet, "/", nil)
testutil.AssertStatus(t, w, http.StatusOK)
var got []database.Department
var got []model.Department
testutil.DecodeJSON(t, w, &got)
if len(got) != 0 {
t.Errorf("expected empty list, got %d", len(got))
@@ -149,7 +149,7 @@ func TestListDepartments_ReturnAll(t *testing.T) {
w := testutil.Do(t, http.HandlerFunc(h.ListDepartments), http.MethodGet, "/", nil)
testutil.AssertStatus(t, w, http.StatusOK)
var got []database.Department
var got []model.Department
testutil.DecodeJSON(t, w, &got)
if len(got) != 3 {
t.Errorf("expected 3 departments, got %d", len(got))
@@ -167,7 +167,7 @@ func TestDeleteDepartment_OK(t *testing.T) {
if err != nil {
t.Fatal(err)
}
var created database.Department
var created model.Department
json.NewDecoder(resp.Body).Decode(&created)
resp.Body.Close()
@@ -209,7 +209,7 @@ func TestCreateGLAccount_OK(t *testing.T) {
testutil.AssertStatus(t, w, http.StatusCreated)
var got database.GLAccount
var got model.GLAccount
testutil.DecodeJSON(t, w, &got)
if got.Code != "5001" {
t.Errorf("code: got %q, want %q", got.Code, "5001")
@@ -256,7 +256,7 @@ func TestListGLAccounts_Empty(t *testing.T) {
w := testutil.Do(t, http.HandlerFunc(h.ListGLAccounts), http.MethodGet, "/", nil)
testutil.AssertStatus(t, w, http.StatusOK)
var got []database.GLAccount
var got []model.GLAccount
testutil.DecodeJSON(t, w, &got)
if len(got) != 0 {
t.Errorf("expected empty list, got %d", len(got))
@@ -273,7 +273,7 @@ func TestListGLAccounts_ReturnAll(t *testing.T) {
w := testutil.Do(t, http.HandlerFunc(h.ListGLAccounts), http.MethodGet, "/", nil)
testutil.AssertStatus(t, w, http.StatusOK)
var got []database.GLAccount
var got []model.GLAccount
testutil.DecodeJSON(t, w, &got)
if len(got) != 2 {
t.Errorf("expected 2 GL accounts, got %d", len(got))
@@ -291,7 +291,7 @@ func TestDeleteGLAccount_OK(t *testing.T) {
if err != nil {
t.Fatal(err)
}
var created database.GLAccount
var created model.GLAccount
json.NewDecoder(resp.Body).Decode(&created)
resp.Body.Close()