Skip to content
This repository has been archived by the owner on Sep 19, 2021. It is now read-only.

Commit

Permalink
Merge pull request #1612 from 18F/wml-clear-yes-no
Browse files Browse the repository at this point in the history
Clear Yes Nos Part 1: Integrations testing in their own database
  • Loading branch information
macrael authored Apr 23, 2019
2 parents 7fc5d2b + 5869a99 commit 6efa34d
Show file tree
Hide file tree
Showing 90 changed files with 1,824 additions and 1,728 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ package-lock.json
/api/bin/submit
/api/bin/transmit
/api/bin/unlock
/api/bin/dbmigrate
/api/bin/dbreset
/build/
/doc/
/dist/
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ test-react:
@docker-compose run --rm js yarn test $(FLAGS) $(FILES)
test-go:
$(info Running Go test suite)
@docker-compose run --rm api make reset-test-db
@docker-compose run --rm api make test

#
Expand Down
7 changes: 7 additions & 0 deletions api/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ all: clean test build
test:
GOLANG_ENV=test go test -coverprofile=coverage.txt -covermode=atomic -cover $(shell go list ./... | grep -v /vendor/)

reset-test-db:
go build -o bin/dbmigrate ./cmd/dbmigrate
go build -o bin/dbreset ./cmd/dbreset
./bin/dbreset -force eapp_test
./bin/dbmigrate -migrations_path ./migrations eapp_test

coverage:
# Use -c to remove processed reports so coverage-js won't find it
codecov -c -F backend -f coverage.txt -X gcov
Expand All @@ -21,6 +27,7 @@ clean:
.PHONY: cmd
cmd:
go build -o bin/compare ./cmd/compare
go build -o bin/dbmigrate ./cmd/dbmigrate
go build -o bin/flush ./cmd/flush
go build -o bin/form ./cmd/form
go build -o bin/fuzzer ./cmd/fuzzer
Expand Down
34 changes: 23 additions & 11 deletions api/account.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package api

import (
"errors"
"fmt"

"github.com/pkg/errors"
)

var (
Expand Down Expand Up @@ -75,10 +76,6 @@ func (entity *Account) Save(context DatabaseService, account int) (int, error) {
return entity.ID, err
}

if err := context.CheckTable(entity); err != nil {
return entity.ID, err
}

if err := context.Save(entity); err != nil {
return entity.ID, err
}
Expand All @@ -88,9 +85,6 @@ func (entity *Account) Save(context DatabaseService, account int) (int, error) {

// Delete the Account entity.
func (entity *Account) Delete(context DatabaseService, account int) (int, error) {
if err := context.CheckTable(entity); err != nil {
return entity.ID, err
}

if entity.ID != 0 {
if err := context.Delete(entity); err != nil {
Expand All @@ -103,9 +97,6 @@ func (entity *Account) Delete(context DatabaseService, account int) (int, error)

// Get the Account entity.
func (entity *Account) Get(context DatabaseService, account int) (int, error) {
if err := context.CheckTable(entity); err != nil {
return entity.ID, err
}

if err := entity.Find(context); err != nil {
return entity.ID, err
Expand Down Expand Up @@ -187,3 +178,24 @@ func (entity *Account) BasicAuthentication(context DatabaseService, password str
}
return nil
}

// ClearNoBranches clears all the branches answered "No" that must be
// re answered after rejection
func (entity *Account) ClearNoBranches(context DatabaseService) error {

// Identification.OtherNames
if err := ClearIdentificationOtherNamesNos(context, entity.ID); err != nil {
return err
}

// Your History
if err := ClearHistoryResidenceNos(context, entity.ID); err != nil {
return err
}

if err := ClearHistoryEmploymentNos(context, entity.ID); err != nil {
return err
}

return nil
}
34 changes: 34 additions & 0 deletions api/admin/reject.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package admin

import (
"github.com/pkg/errors"

"github.com/18F/e-QIP-prototype/api"
)

// Rejector is used to reject/kickback an application
type Rejector struct {
DB api.DatabaseService
PDF api.PdfService
}

// Reject rejects the application for a given account
func (r Rejector) Reject(account api.Account) error {
err := account.Unlock(r.DB)
if err != nil {
return errors.Wrap(err, "Reject failed to unlock account")
}

// TODO: port over PDF.RemovePdfs.
// err = r.PDF.RemovePdfs(account)
// if err != nil {
// return errors.Wrap(err, "Reject failed to remove PDFs")
// }

err = account.ClearNoBranches(r.DB)
if err != nil {
return errors.Wrap(err, "Reject failed to clear the no branches")
}

return nil
}
13 changes: 0 additions & 13 deletions api/attachment.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ func (entity *Attachment) Valid() (bool, error) {
// Save the attachment.
func (entity *Attachment) Save(context DatabaseService, account int) (int, error) {
entity.AccountID = account

if err := context.CheckTable(entity); err != nil {
return entity.ID, err
}

if err := context.Save(entity); err != nil {
return entity.ID, err
}
Expand All @@ -56,10 +51,6 @@ func (entity *Attachment) Save(context DatabaseService, account int) (int, error

// Delete the attachment.
func (entity *Attachment) Delete(context DatabaseService, account int) (int, error) {
if err := context.CheckTable(entity); err != nil {
return entity.ID, err
}

if entity.ID != 0 {
if err := context.Delete(entity); err != nil {
return entity.ID, err
Expand All @@ -71,10 +62,6 @@ func (entity *Attachment) Delete(context DatabaseService, account int) (int, err

// Get the attachment.
func (entity *Attachment) Get(context DatabaseService, account int) (int, error) {
if err := context.CheckTable(entity); err != nil {
return entity.ID, err
}

if entity.ID != 0 {
if err := context.Select(entity); err != nil {
return entity.ID, err
Expand Down
9 changes: 0 additions & 9 deletions api/basicauth_membership.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ type BasicAuthMembership struct {

// Save the basic membership.
func (entity *BasicAuthMembership) Save(context DatabaseService, account int) (int, error) {
if err := context.CheckTable(entity); err != nil {
return entity.ID, err
}

if err := context.Save(entity); err != nil {
return entity.ID, err
Expand All @@ -30,9 +27,6 @@ func (entity *BasicAuthMembership) Save(context DatabaseService, account int) (i

// Delete the basic membership.
func (entity *BasicAuthMembership) Delete(context DatabaseService, account int) (int, error) {
if err := context.CheckTable(entity); err != nil {
return entity.ID, err
}

if entity.ID != 0 {
if err := context.Delete(entity); err != nil {
Expand All @@ -45,9 +39,6 @@ func (entity *BasicAuthMembership) Delete(context DatabaseService, account int)

// Get the basic membership.
func (entity *BasicAuthMembership) Get(context DatabaseService, account int) (int, error) {
if err := context.CheckTable(entity); err != nil {
return entity.ID, err
}

if err := entity.Find(context); err != nil {
return entity.ID, err
Expand Down
12 changes: 0 additions & 12 deletions api/benefit.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,6 @@ func (entity *Benefit) Valid() (bool, error) {
func (entity *Benefit) Save(context DatabaseService, account int) (int, error) {
entity.AccountID = account

if err := context.CheckTable(entity); err != nil {
return entity.ID, err
}

if err := entity.Find(context); err != nil {
return entity.ID, err
}
Expand Down Expand Up @@ -319,10 +315,6 @@ func (entity *Benefit) Save(context DatabaseService, account int) (int, error) {
func (entity *Benefit) Delete(context DatabaseService, account int) (int, error) {
entity.AccountID = account

if err := context.CheckTable(entity); err != nil {
return entity.ID, err
}

if err := entity.Find(context); err != nil {
return entity.ID, err
}
Expand Down Expand Up @@ -400,10 +392,6 @@ func (entity *Benefit) Delete(context DatabaseService, account int) (int, error)
func (entity *Benefit) Get(context DatabaseService, account int) (int, error) {
entity.AccountID = account

if err := context.CheckTable(entity); err != nil {
return entity.ID, err
}

if err := entity.Find(context); err != nil {
return entity.ID, err
}
Expand Down
12 changes: 0 additions & 12 deletions api/branch.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ func (entity *Branch) Valid() (bool, error) {

// Save the Branch entity.
func (entity *Branch) Save(context DatabaseService, account int) (int, error) {
if err := context.CheckTable(entity); err != nil {
return entity.ID, err
}

if err := context.Save(entity); err != nil {
return entity.ID, err
}
Expand All @@ -52,10 +48,6 @@ func (entity *Branch) Save(context DatabaseService, account int) (int, error) {

// Delete the Branch entity.
func (entity *Branch) Delete(context DatabaseService, account int) (int, error) {
if err := context.CheckTable(entity); err != nil {
return entity.ID, err
}

if entity.ID != 0 {
if err := context.Delete(entity); err != nil {
return entity.ID, err
Expand All @@ -67,10 +59,6 @@ func (entity *Branch) Delete(context DatabaseService, account int) (int, error)

// Get the Branch entity.
func (entity *Branch) Get(context DatabaseService, account int) (int, error) {
if err := context.CheckTable(entity); err != nil {
return entity.ID, err
}

if entity.ID != 0 {
if err := context.Select(entity); err != nil {
return entity.ID, err
Expand Down
12 changes: 0 additions & 12 deletions api/checkbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ func (entity *Checkbox) Valid() (bool, error) {

// Save the checkbox to data storage.
func (entity *Checkbox) Save(context DatabaseService, account int) (int, error) {
if err := context.CheckTable(entity); err != nil {
return entity.ID, err
}

if err := context.Save(entity); err != nil {
return entity.ID, err
}
Expand All @@ -39,10 +35,6 @@ func (entity *Checkbox) Save(context DatabaseService, account int) (int, error)

// Delete the checkbox from data storage.
func (entity *Checkbox) Delete(context DatabaseService, account int) (int, error) {
if err := context.CheckTable(entity); err != nil {
return entity.ID, err
}

if entity.ID != 0 {
if err := context.Delete(entity); err != nil {
return entity.ID, err
Expand All @@ -54,10 +46,6 @@ func (entity *Checkbox) Delete(context DatabaseService, account int) (int, error

// Get the checkbox from data storage.
func (entity *Checkbox) Get(context DatabaseService, account int) (int, error) {
if err := context.CheckTable(entity); err != nil {
return entity.ID, err
}

if entity.ID != 0 {
if err := context.Select(entity); err != nil {
return entity.ID, err
Expand Down
12 changes: 0 additions & 12 deletions api/checkboxgroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ func (entity *CheckboxGroup) Valid() (bool, error) {

// Save the checkbox group to data storage.
func (entity *CheckboxGroup) Save(context DatabaseService, account int) (int, error) {
if err := context.CheckTable(entity); err != nil {
return entity.ID, err
}

if err := context.Save(entity); err != nil {
return entity.ID, err
}
Expand All @@ -38,10 +34,6 @@ func (entity *CheckboxGroup) Save(context DatabaseService, account int) (int, er

// Delete the checkbox group to data storage.
func (entity *CheckboxGroup) Delete(context DatabaseService, account int) (int, error) {
if err := context.CheckTable(entity); err != nil {
return entity.ID, err
}

if entity.ID != 0 {
if err := context.Delete(entity); err != nil {
return entity.ID, err
Expand All @@ -53,10 +45,6 @@ func (entity *CheckboxGroup) Delete(context DatabaseService, account int) (int,

// Get the checkbox group to data storage.
func (entity *CheckboxGroup) Get(context DatabaseService, account int) (int, error) {
if err := context.CheckTable(entity); err != nil {
return entity.ID, err
}

if entity.ID != 0 {
if err := context.Select(entity); err != nil {
return entity.ID, err
Expand Down
Loading

0 comments on commit 6efa34d

Please sign in to comment.