Skip to content

Commit

Permalink
done
Browse files Browse the repository at this point in the history
  • Loading branch information
garrettladley committed Jan 27, 2024
1 parent 578586f commit a73ea8c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 46 deletions.
38 changes: 19 additions & 19 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@

1. **Clone the repository**

```bash
```console
git clone [email protected]:GenerateNU/sac.git
```

2. **Install dependencies**

```bash
```console
cd frontend/*
yarn install
```

- If you get an error about `expo-cli` not being installed, run `yarn global add expo-cli` and then run `yarn install` again.

```bash
```console
cd server
go get ./...
```
Expand All @@ -46,7 +46,7 @@

1. **Create client build**

```bash
```console
cd frotend/sac-mobile
eas login
eas build:configure
Expand All @@ -61,7 +61,7 @@

3. **Start the client**

```bash
```console
cd frontend/sac-mobile
npx expo start --dev-client
```
Expand All @@ -74,50 +74,50 @@

- MacOS

```bash
```console
brew services start postgresql@15
```

- Windows

```bash
```console
pg_ctl -D /usr/local/var/postgres start
```

2. **Create a user**

```bash
```console
createdb
```

3. **Create a database**

```bash
```console
psql // opens psql shell
CREATE DATABASE sac;
```

4. **Create a user**

```bash
```console
createuser postgres -U <your username>
```

# Commands

### React Native
## React Native

```bash
```console
npx expo start --dev-client // runnning dev client
npx expo start --dev-client --ios // specific platform
yarn format // format code
yarn lint // lint code
yarn test // run tests
```

### Go
## Go

```bash
```console
go run main.go // run server
go test ./... // run tests
go fmt ./... // format code
Expand All @@ -128,7 +128,7 @@

To install use `./install.sh` and then run `sac-cli` to see all commands.

```bash
```console
sac-cli migrate // run migrations
sac-cli reset // reset database
sac-cli swagger // generate swagger docs
Expand All @@ -141,15 +141,15 @@

1. **Create a new branch**

```bash
```console
git checkout -b <branch-name> // this is determined by your ticket name
```

2. **Make changes and commit changes:**

- **Commit changes**

```bash
```console
git add .
git commit
```
Expand All @@ -160,13 +160,13 @@

3. **Push changes to GitHub**

```bash
```console
git push
```

or

```bash
```console
git push origin <branch-name>
```

Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,11 @@
alt="Go Workflow Status" />
</a>
</div>

## Contributors

<div align="center">
<a href="https://github.com/GenerateNU/sac/graphs/contributors">
<img src="https://contrib.rocks/image?repo=GenerateNU/sac" height="50px"/>
</a>
</div>
28 changes: 1 addition & 27 deletions backend/tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ TestRequest{
Path: "/api/v1/tags/",
Body: &map[string]interface{}{
"name": tagName,
"category_id": 1,
"category_id": uuid.New(),
},
}
```
Expand Down Expand Up @@ -93,32 +93,6 @@ func AssertCategoryWithIDBodyRespDB(app TestApp, assert *assert.A, resp *http.Re

Since the test suite creates a new database for each test, we can have a deterministic database state for each test. However, what if we have a multi step test that depends on the previous steps database state? That is where `ExistingAppAssert` comes in! This will allow us to keep using the database from a previous step in the test.

Consider this example, to create a tag, we need to create a category first. This is a multi step test, so we need to use `ExistingAppAssert` to keep the database state from the previous step.

```go
TestRequest{
Method: fiber.MethodPost,
Path: "/api/v1/categories/",
Body: SampleCategoryFactory(),
}.TestOnStatusAndDB(t, nil,
DBTesterWithStatus{
Status: fiber.StatusCreated,
DBTester: AssertSampleCategoryBodyRespDB,
},
)

TestRequest{
Method: fiber.MethodPost,
Path: "/api/v1/tags/",
Body: SampleTagFactory(),
}.TestOnStatusAndDB(t, &appAssert,
DBTesterWithStatus{
Status: fiber.StatusCreated,
DBTester: AssertSampleTagBodyRespDB,
},
).Close()
```

### Why Close?

This closes the connection to the database. This is important because if you don't close the connection, we will run out of available connections and the tests will fail. **Call this on the last test request of a test**
Expand Down

0 comments on commit a73ea8c

Please sign in to comment.