From a7012b6e8d8a900ab31ea4bd5f4f9a3b10406553 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Tue, 10 Apr 2018 12:37:59 +0200 Subject: [PATCH] Added installation script for developers --- INSTALLATION.md | 28 ++++++---------------------- install.sh | 39 +++++++++++++++++++++++++++++++++++++++ main_test.go | 6 +++++- 3 files changed, 50 insertions(+), 23 deletions(-) diff --git a/INSTALLATION.md b/INSTALLATION.md index d79226bb..2c6da755 100644 --- a/INSTALLATION.md +++ b/INSTALLATION.md @@ -11,7 +11,7 @@ * Install [TypeScript](https://www.typescriptlang.org/) (2.6 or higher) * Install [Git LFS](https://git-lfs.github.com/) -## Check +## Confirm that prerequisites are installed ```bash go version @@ -19,29 +19,13 @@ tsc --version git lfs version ``` -## Download the repository +## Start the installation -* `go get github.com/animenotifier/notify.moe/...` +```bash +curl -s https://raw.githubusercontent.com/animenotifier/notify.moe/go/install.sh | sudo bash +``` -## Build all - -* `cd $GOPATH/src/github.com/animenotifier/notify.moe` -* `make all` - -## Browser - -* `make ports` to set up local port forwarding *(80 to 4000, 443 to 4001)* -* `make browser` to start Google Chrome - -## Database - -* `git clone https://github.com/animenotifier/database ~/.aero/db/arn` - -## Hosts - -* Add `127.0.0.1 beta.notify.moe` to `/etc/hosts` - -## Run +## Run the server * Start the web server in notify.moe directory: `run` * Open `https://beta.notify.moe` which should now resolve to localhost diff --git a/install.sh b/install.sh index c3596ea8..fb27099c 100755 --- a/install.sh +++ b/install.sh @@ -1,7 +1,41 @@ #!/bin/bash +echo "Checking prerequisites..." + +if hash go 2>/dev/null; then + go version +else + echo "Go is not installed" + exit +fi + +if hash tsc 2>/dev/null; then + tsc --version +else + echo "TypeScript is not installed" + exit +fi + +if hash git 2>/dev/null; then + git version +else + echo "Git is not installed" + exit +fi + +if hash git-lfs 2>/dev/null; then + git lfs version +else + echo "Git LFS is not installed" + exit +fi + +echo "Looks like the prerequisites were installed correctly!" +echo "---" + # Clone and build main repository go get -v github.com/animenotifier/notify.moe/... +go get -v github.com/stretchr/testify/assert cd $GOPATH/src/github.com/animenotifier/notify.moe make all @@ -10,4 +44,9 @@ git clone https://github.com/animenotifier/database ~/.aero/db/arn # Configure make ports + +# Add "127.0.0.1 beta.notify.moe" to /etc/hosts sudo -- sh -c -e "echo '127.0.0.1 beta.notify.moe' >> /etc/hosts" + +# Test +make test \ No newline at end of file diff --git a/main_test.go b/main_test.go index a29b7ae7..0417e7d9 100644 --- a/main_test.go +++ b/main_test.go @@ -28,8 +28,12 @@ func TestRouteStatusCodes(t *testing.T) { // Record the response without actually starting the server responseRecorder := httptest.NewRecorder() app.Handler().ServeHTTP(responseRecorder, request) + status := responseRecorder.Code - if status := responseRecorder.Code; status != http.StatusOK { + switch status { + case 200, 302: + // 200 and 302 are allowed + default: panic(fmt.Errorf("%s | Wrong status code | %v instead of %v", example, status, http.StatusOK)) } }