mirror of https://github.com/statping/statping
footer fix - SASS compile fix - additional testing
parent
2aa466a622
commit
4ab4b1f5c0
|
@ -1,11 +1,12 @@
|
||||||
.git
|
**
|
||||||
.gitignore
|
|
||||||
Dockerfile
|
!/source
|
||||||
Dockerfile-dev
|
!/types
|
||||||
.travis.yml
|
!/utils
|
||||||
.travis
|
!/plugin
|
||||||
servers
|
!/notifiers
|
||||||
build
|
!/handlers
|
||||||
logs
|
!/core
|
||||||
coverage.out
|
!/cmd
|
||||||
*.db
|
!/Makefile
|
||||||
|
!/README.md
|
|
@ -55,12 +55,11 @@ before_script:
|
||||||
- mysql -e 'CREATE DATABASE IF NOT EXISTS test;'
|
- mysql -e 'CREATE DATABASE IF NOT EXISTS test;'
|
||||||
- psql -c 'create database test;' -U postgres
|
- psql -c 'create database test;' -U postgres
|
||||||
- make deps
|
- make deps
|
||||||
|
- make install
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- make install
|
|
||||||
- make test
|
- make test
|
||||||
- if [[ "$TRAVIS_BRANCH" == "master" ]]; then make coverage; fi
|
- if [[ "$TRAVIS_BRANCH" == "master" ]]; then make coverage; fi
|
||||||
- make docker-test
|
|
||||||
|
|
||||||
after_success:
|
after_success:
|
||||||
- if [[ "$TRAVIS_BRANCH" == "master" ]]; then travis_wait 30 docker pull karalabe/xgo-latest; fi
|
- if [[ "$TRAVIS_BRANCH" == "master" ]]; then travis_wait 30 docker pull karalabe/xgo-latest; fi
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
FROM golang:1.10.3-alpine
|
||||||
|
|
||||||
|
RUN apk add --no-cache libstdc++ gcc g++ make git ca-certificates linux-headers
|
||||||
|
|
||||||
|
RUN wget -q https://assets.statup.io/sass && \
|
||||||
|
chmod +x sass && \
|
||||||
|
mv sass /usr/local/bin/sass
|
||||||
|
RUN sass -v
|
||||||
|
|
||||||
|
WORKDIR $GOPATH/src/github.com/hunterlong/statup
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
RUN make deps
|
||||||
|
RUN make compile
|
||||||
|
RUN make install
|
||||||
|
|
||||||
|
ENV VERSION=$(VERSION)
|
||||||
|
ENV IS_DOCKER=true
|
||||||
|
ENV SASS=/usr/local/bin/sass
|
||||||
|
ENV ONLY_DB=sqlite
|
||||||
|
ENV STATUP_DIR=/go/src/github.com/hunterlong/statup
|
||||||
|
ENV GO_ENV=test
|
||||||
|
|
||||||
|
EXPOSE 8080
|
||||||
|
ENTRYPOINT SASS=$(SASS) VERSION=$(VERSION) make test
|
|
@ -1,30 +0,0 @@
|
||||||
FROM golang:1.10.3
|
|
||||||
|
|
||||||
WORKDIR $GOPATH/src/github.com/hunterlong/statup
|
|
||||||
|
|
||||||
COPY . .
|
|
||||||
ADD ./Makefile ./Makefile
|
|
||||||
RUN make deps
|
|
||||||
RUN make compile
|
|
||||||
RUN make install
|
|
||||||
|
|
||||||
RUN apt update && \
|
|
||||||
apt install -y postgresql apg
|
|
||||||
|
|
||||||
RUN wget -q https://assets.statup.io/sass && \
|
|
||||||
chmod +x sass && \
|
|
||||||
mv sass /usr/local/bin/sass
|
|
||||||
|
|
||||||
ENV VERSION=$(VERSION)
|
|
||||||
ENV IS_DOCKER=true
|
|
||||||
ENV SASS=/usr/local/bin/sass
|
|
||||||
ENV CMD_FILE=/usr/bin/cmd
|
|
||||||
ENV ONLY_DB=sqlite
|
|
||||||
ENV STATUP_DIR=/go/src/github.com/hunterlong/statup
|
|
||||||
ENV GO_ENV=test
|
|
||||||
|
|
||||||
RUN printf "#!/usr/bin/env sh\n\$1\n" > $CMD_FILE && \
|
|
||||||
chmod +x $CMD_FILE
|
|
||||||
|
|
||||||
EXPOSE 8080
|
|
||||||
ENTRYPOINT go test ./... -p 1 -ldflags="-X main.VERSION=$(VERSION)" -coverprofile=coverage.out -v
|
|
30
Makefile
30
Makefile
|
@ -1,4 +1,4 @@
|
||||||
VERSION=0.4
|
VERSION=0.41
|
||||||
GOPATH:=$(GOPATH)
|
GOPATH:=$(GOPATH)
|
||||||
GOCMD=go
|
GOCMD=go
|
||||||
GOBUILD=$(GOCMD) build
|
GOBUILD=$(GOCMD) build
|
||||||
|
@ -20,11 +20,11 @@ all: deps compile install clean
|
||||||
|
|
||||||
release: deps build-all compress
|
release: deps build-all compress
|
||||||
|
|
||||||
install: build
|
install: clean build
|
||||||
mv $(BINARY_NAME) $(GOPATH)/bin/$(BINARY_NAME)
|
mv $(BINARY_NAME) $(GOPATH)/bin/$(BINARY_NAME)
|
||||||
$(GOPATH)/bin/$(BINARY_NAME) version
|
$(GOPATH)/bin/$(BINARY_NAME) version
|
||||||
|
|
||||||
build:
|
build: compile
|
||||||
$(GOBUILD) -ldflags="-X main.VERSION=$(VERSION)" -o $(BINARY_NAME) -v ./cmd
|
$(GOBUILD) -ldflags="-X main.VERSION=$(VERSION)" -o $(BINARY_NAME) -v ./cmd
|
||||||
|
|
||||||
run: build
|
run: build
|
||||||
|
@ -34,8 +34,8 @@ compile:
|
||||||
cd source && $(GOPATH)/bin/rice embed-go
|
cd source && $(GOPATH)/bin/rice embed-go
|
||||||
$(GOPATH)/bin/wt compile source/scss/base.scss -b source/css
|
$(GOPATH)/bin/wt compile source/scss/base.scss -b source/css
|
||||||
|
|
||||||
test: compile test-env
|
test: clean compile test-env
|
||||||
$(GOTEST) ./... -p 1 -ldflags="-X main.VERSION=$(VERSION)" -coverprofile=coverage.out -v
|
gocov test -v ./... -p 1 -ldflags="-X main.VERSION=$(VERSION)" -covermode=count > coverage.json
|
||||||
|
|
||||||
test-all: compile test-env databases
|
test-all: compile test-env databases
|
||||||
$(GOTEST) ./... -p 1 -ldflags="-X main.VERSION=$(VERSION)" -coverprofile=coverage.out -v
|
$(GOTEST) ./... -p 1 -ldflags="-X main.VERSION=$(VERSION)" -coverprofile=coverage.out -v
|
||||||
|
@ -43,6 +43,11 @@ test-all: compile test-env databases
|
||||||
coverage:
|
coverage:
|
||||||
$(GOPATH)/bin/goveralls -coverprofile=coverage.out -service=travis -repotoken $(COVERALLS)
|
$(GOPATH)/bin/goveralls -coverprofile=coverage.out -service=travis -repotoken $(COVERALLS)
|
||||||
|
|
||||||
|
docs:
|
||||||
|
godoc2md github.com/hunterlong/statup > servers/docs/README.md
|
||||||
|
gocov-html coverage.json > servers/docs/COVERAGE.html
|
||||||
|
revive -formatter stylish > servers/docs/LINT.md
|
||||||
|
|
||||||
build-all: clean compile
|
build-all: clean compile
|
||||||
mkdir build
|
mkdir build
|
||||||
$(XGO) $(BUILDVERSION) --targets=darwin/amd64 ./cmd
|
$(XGO) $(BUILDVERSION) --targets=darwin/amd64 ./cmd
|
||||||
|
@ -55,10 +60,10 @@ build-all: clean compile
|
||||||
$(XGO) --targets=linux/amd64 -ldflags="-X main.VERSION=$VERSION -linkmode external -extldflags -static" -out alpine ./cmd
|
$(XGO) --targets=linux/amd64 -ldflags="-X main.VERSION=$VERSION -linkmode external -extldflags -static" -out alpine ./cmd
|
||||||
|
|
||||||
docker:
|
docker:
|
||||||
$(DOCKER) build -t hunterlong/statup:latest .
|
$(DOCKER) build -t hunterlong/statup:latest -f ./cmd/Dockerfile .
|
||||||
|
|
||||||
docker-dev:
|
docker-dev:
|
||||||
$(DOCKER) build -t hunterlong/statup:dev -f Dockerfile-dev .
|
$(DOCKER) build -t hunterlong/statup:dev -f ./.travis/Dockerfile .
|
||||||
|
|
||||||
docker-run: docker
|
docker-run: docker
|
||||||
$(DOCKER) run -t -p 8080:8080 hunterlong/statup:latest
|
$(DOCKER) run -t -p 8080:8080 hunterlong/statup:latest
|
||||||
|
@ -85,6 +90,12 @@ deps:
|
||||||
$(GOGET) github.com/GeertJohan/go.rice
|
$(GOGET) github.com/GeertJohan/go.rice
|
||||||
$(GOGET) github.com/GeertJohan/go.rice/rice
|
$(GOGET) github.com/GeertJohan/go.rice/rice
|
||||||
$(GOINSTALL) github.com/GeertJohan/go.rice/rice
|
$(GOINSTALL) github.com/GeertJohan/go.rice/rice
|
||||||
|
$(GOCMD) get github.com/davecheney/godoc2md
|
||||||
|
$(GOCMD) install github.com/davecheney/godoc2md
|
||||||
|
$(GOCMD) get github.com/axw/gocov/gocov
|
||||||
|
$(GOCMD) get -u gopkg.in/matm/v1/gocov-html
|
||||||
|
$(GOCMD) install gopkg.in/matm/v1/gocov-html
|
||||||
|
$(GOCMD) get -u github.com/mgechev/revive
|
||||||
$(GOGET) -d ./...
|
$(GOGET) -d ./...
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
@ -117,7 +128,6 @@ test-env:
|
||||||
export DB_PASS=password123
|
export DB_PASS=password123
|
||||||
export DB_DATABASE=root
|
export DB_DATABASE=root
|
||||||
export NAME=Demo
|
export NAME=Demo
|
||||||
export CMD_FILE=$(GOPATH)/src/github.com/hunterlong/statup/cmd.sh
|
|
||||||
export STATUP_DIR=$(GOPATH)/src/github.com/hunterlong/statup
|
export STATUP_DIR=$(GOPATH)/src/github.com/hunterlong/statup
|
||||||
|
|
||||||
compress:
|
compress:
|
||||||
|
@ -154,4 +164,6 @@ publish:
|
||||||
-d "$(PUBLISH_BODY)" \
|
-d "$(PUBLISH_BODY)" \
|
||||||
https://api.travis-ci.com/repo/hunterlong%2Fstatup-testing/requests
|
https://api.travis-ci.com/repo/hunterlong%2Fstatup-testing/requests
|
||||||
curl -H "Content-Type: application/json" \
|
curl -H "Content-Type: application/json" \
|
||||||
--data '{"docker_tag": "dev"}' -X POST $(DOCKER)
|
--data '{"docker_tag": "dev"}' -X POST $(DOCKER)
|
||||||
|
|
||||||
|
.PHONY: build build-all
|
|
@ -141,8 +141,7 @@ Statup accepts Push Requests! Feel free to add your own features and notifiers.
|
||||||
|
|
||||||
[](https://goreportcard.com/report/github.com/hunterlong/statup)
|
[](https://goreportcard.com/report/github.com/hunterlong/statup)
|
||||||
[](https://travis-ci.org/hunterlong/statup) [](https://dashboard.cypress.io/#/projects/bi8mhr/runs)
|
[](https://travis-ci.org/hunterlong/statup) [](https://dashboard.cypress.io/#/projects/bi8mhr/runs)
|
||||||
[](https://hub.docker.com/r/hunterlong/statup/builds/)
|
[](https://hub.docker.com/r/hunterlong/statup/builds/) [](https://godoc.org/github.com/hunterlong/statup)[](https://coveralls.io/github/hunterlong/statup?branch=master)
|
||||||
[](https://godoc.org/github.com/hunterlong/statup)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -14,10 +14,7 @@ RUN wget -q https://assets.statup.io/sass && \
|
||||||
|
|
||||||
ENV IS_DOCKER=true
|
ENV IS_DOCKER=true
|
||||||
ENV SASS=/usr/local/bin/sass
|
ENV SASS=/usr/local/bin/sass
|
||||||
ENV CMD_FILE=/usr/bin/cmd
|
ENV STATUP_DIR=/app
|
||||||
|
|
||||||
RUN printf "#!/usr/bin/env sh\n\$1\n" > $CMD_FILE && \
|
|
||||||
chmod +x $CMD_FILE
|
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
VOLUME /app
|
VOLUME /app
|
26
cmd/cli.go
26
cmd/cli.go
|
@ -2,6 +2,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/hunterlong/statup/core"
|
"github.com/hunterlong/statup/core"
|
||||||
"github.com/hunterlong/statup/source"
|
"github.com/hunterlong/statup/source"
|
||||||
|
@ -11,7 +12,6 @@ import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
"upper.io/db.v3/sqlite"
|
"upper.io/db.v3/sqlite"
|
||||||
|
@ -22,21 +22,23 @@ const (
|
||||||
POINT = " "
|
POINT = " "
|
||||||
)
|
)
|
||||||
|
|
||||||
func CatchCLI(args []string) {
|
func CatchCLI(args []string) error {
|
||||||
dir := utils.Directory
|
dir := utils.Directory
|
||||||
|
source.Assets()
|
||||||
switch args[1] {
|
switch args[1] {
|
||||||
case "version":
|
case "version":
|
||||||
fmt.Printf("Statup v%v\n", VERSION)
|
fmt.Printf("Statup v%v\n", VERSION)
|
||||||
|
return nil
|
||||||
case "assets":
|
case "assets":
|
||||||
source.Assets()
|
err := source.CreateAllAssets(dir)
|
||||||
source.CreateAllAssets(dir)
|
return err
|
||||||
case "sass":
|
case "sass":
|
||||||
source.CompileSASS(dir)
|
err := source.CompileSASS(dir)
|
||||||
|
return err
|
||||||
case "update":
|
case "update":
|
||||||
gitCurrent, err := CheckGithubUpdates()
|
gitCurrent, err := CheckGithubUpdates()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
return nil
|
||||||
os.Exit(2)
|
|
||||||
}
|
}
|
||||||
fmt.Printf("Statup Version: v%v\nLatest Version: %v\n", VERSION, gitCurrent.TagName)
|
fmt.Printf("Statup Version: v%v\nLatest Version: %v\n", VERSION, gitCurrent.TagName)
|
||||||
if VERSION != gitCurrent.TagName[1:] {
|
if VERSION != gitCurrent.TagName[1:] {
|
||||||
|
@ -44,19 +46,21 @@ func CatchCLI(args []string) {
|
||||||
} else {
|
} else {
|
||||||
fmt.Printf("You have the latest version of Statup!\n")
|
fmt.Printf("You have the latest version of Statup!\n")
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
case "test":
|
case "test":
|
||||||
cmd := args[2]
|
cmd := args[2]
|
||||||
switch cmd {
|
switch cmd {
|
||||||
case "plugins":
|
case "plugins":
|
||||||
LoadPlugins(true)
|
LoadPlugins(true)
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
case "export":
|
case "export":
|
||||||
var err error
|
var err error
|
||||||
fmt.Printf("Statup v%v Exporting Static 'index.html' page...\n", VERSION)
|
fmt.Printf("Statup v%v Exporting Static 'index.html' page...\n", VERSION)
|
||||||
source.Assets()
|
|
||||||
core.Configs, err = core.LoadConfig()
|
core.Configs, err = core.LoadConfig()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.Log(4, "config.yml file not found")
|
utils.Log(4, "config.yml file not found")
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
RunOnce()
|
RunOnce()
|
||||||
indexSource := core.ExportIndexHTML()
|
indexSource := core.ExportIndexHTML()
|
||||||
|
@ -67,22 +71,27 @@ func CatchCLI(args []string) {
|
||||||
utils.Log(1, "Exported Statup index page: 'index.html'")
|
utils.Log(1, "Exported Statup index page: 'index.html'")
|
||||||
case "help":
|
case "help":
|
||||||
HelpEcho()
|
HelpEcho()
|
||||||
|
return nil
|
||||||
case "run":
|
case "run":
|
||||||
utils.Log(1, "Running 1 time and saving to database...")
|
utils.Log(1, "Running 1 time and saving to database...")
|
||||||
RunOnce()
|
RunOnce()
|
||||||
fmt.Println("Check is complete.")
|
fmt.Println("Check is complete.")
|
||||||
|
return nil
|
||||||
case "env":
|
case "env":
|
||||||
fmt.Println("Statup Environment Variables")
|
fmt.Println("Statup Environment Variables")
|
||||||
envs, err := godotenv.Read(".env")
|
envs, err := godotenv.Read(".env")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.Log(4, "No .env file found in current directory.")
|
utils.Log(4, "No .env file found in current directory.")
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
for k, e := range envs {
|
for k, e := range envs {
|
||||||
fmt.Printf("%v=%v\n", k, e)
|
fmt.Printf("%v=%v\n", k, e)
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
utils.Log(3, "Statup does not have the command you entered.")
|
utils.Log(3, "Statup does not have the command you entered.")
|
||||||
|
return errors.New("statup does not have the command you entered")
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func RunOnce() {
|
func RunOnce() {
|
||||||
|
@ -118,6 +127,7 @@ func HelpEcho() {
|
||||||
fmt.Println(" statup run - Check all services 1 time and then quit")
|
fmt.Println(" statup run - Check all services 1 time and then quit")
|
||||||
fmt.Println(" statup test plugins - Test all plugins for required information")
|
fmt.Println(" statup test plugins - Test all plugins for required information")
|
||||||
fmt.Println(" statup assets - Dump all assets used locally to be edited.")
|
fmt.Println(" statup assets - Dump all assets used locally to be edited.")
|
||||||
|
fmt.Println(" statup sass - Compile .scss files into the css directory")
|
||||||
fmt.Println(" statup env - Show all environment variables being used for Statup")
|
fmt.Println(" statup env - Show all environment variables being used for Statup")
|
||||||
fmt.Println(" statup export - Exports the index page as a static HTML for pushing")
|
fmt.Println(" statup export - Exports the index page as a static HTML for pushing")
|
||||||
fmt.Println(" statup update - Attempts to update to the latest version")
|
fmt.Println(" statup update - Attempts to update to the latest version")
|
||||||
|
|
|
@ -0,0 +1,87 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/rendon/testcli"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
"os"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestVersionCommand(t *testing.T) {
|
||||||
|
c := testcli.Command("statup", "version")
|
||||||
|
c.Run()
|
||||||
|
assert.True(t, c.StdoutContains("Statup v"+VERSION))
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestHelpCommand(t *testing.T) {
|
||||||
|
c := testcli.Command("statup", "help")
|
||||||
|
c.Run()
|
||||||
|
t.Log(c.Stdout())
|
||||||
|
assert.True(t, c.StdoutContains("statup help - Shows the user basic information about Statup"))
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestExportCommand(t *testing.T) {
|
||||||
|
t.SkipNow()
|
||||||
|
c := testcli.Command("statup", "export")
|
||||||
|
c.Run()
|
||||||
|
t.Log(c.Stdout())
|
||||||
|
assert.True(t, c.StdoutContains("Exporting Static 'index.html' page"))
|
||||||
|
assert.True(t, fileExists(dir+"/cmd/index.html"))
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestAssetsCommand(t *testing.T) {
|
||||||
|
c := testcli.Command("statup", "assets")
|
||||||
|
c.Run()
|
||||||
|
t.Log(c.Stdout())
|
||||||
|
t.Log("Directory for Assets: ", dir)
|
||||||
|
assert.FileExists(t, dir+"/assets/robots.txt")
|
||||||
|
assert.FileExists(t, dir+"/assets/js/main.js")
|
||||||
|
assert.FileExists(t, dir+"/assets/scss/base.scss")
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestVersionCLI(t *testing.T) {
|
||||||
|
run := CatchCLI([]string{"statup", "version"})
|
||||||
|
assert.Nil(t, run)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestAssetsCLI(t *testing.T) {
|
||||||
|
run := CatchCLI([]string{"statup", "assets"})
|
||||||
|
assert.Nil(t, run)
|
||||||
|
assert.FileExists(t, "../assets/css/base.css")
|
||||||
|
assert.FileExists(t, "../assets/scss/base.scss")
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestSassCLI(t *testing.T) {
|
||||||
|
if os.Getenv("IS_DOCKER") == "true" {
|
||||||
|
os.Setenv("SASS", "/usr/local/bin/sass")
|
||||||
|
}
|
||||||
|
run := CatchCLI([]string{"statup", "sass"})
|
||||||
|
assert.Nil(t, run)
|
||||||
|
assert.FileExists(t, "../assets/css/base.css")
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestUpdateCLI(t *testing.T) {
|
||||||
|
run := CatchCLI([]string{"statup", "update"})
|
||||||
|
assert.Nil(t, run)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestTestPackageCLI(t *testing.T) {
|
||||||
|
run := CatchCLI([]string{"statup", "test", "plugins"})
|
||||||
|
assert.Nil(t, run)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestHelpCLI(t *testing.T) {
|
||||||
|
run := CatchCLI([]string{"statup", "help"})
|
||||||
|
assert.Nil(t, run)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestRunOnceCLI(t *testing.T) {
|
||||||
|
t.SkipNow()
|
||||||
|
run := CatchCLI([]string{"statup", "run"})
|
||||||
|
assert.Nil(t, run)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestEnvCLI(t *testing.T) {
|
||||||
|
run := CatchCLI([]string{"statup", "env"})
|
||||||
|
assert.Error(t, run)
|
||||||
|
}
|
|
@ -30,7 +30,11 @@ func init() {
|
||||||
func main() {
|
func main() {
|
||||||
var err error
|
var err error
|
||||||
if len(os.Args) >= 2 {
|
if len(os.Args) >= 2 {
|
||||||
CatchCLI(os.Args)
|
err := CatchCLI(os.Args)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
utils.Log(1, fmt.Sprintf("Starting Statup v%v", VERSION))
|
utils.Log(1, fmt.Sprintf("Starting Statup v%v", VERSION))
|
||||||
|
|
|
@ -9,7 +9,6 @@ import (
|
||||||
"github.com/hunterlong/statup/source"
|
"github.com/hunterlong/statup/source"
|
||||||
"github.com/hunterlong/statup/types"
|
"github.com/hunterlong/statup/types"
|
||||||
"github.com/hunterlong/statup/utils"
|
"github.com/hunterlong/statup/utils"
|
||||||
"github.com/rendon/testcli"
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
|
@ -50,7 +49,6 @@ func TestRunAll(t *testing.T) {
|
||||||
if os.Getenv("ONLY_DB") != "" {
|
if os.Getenv("ONLY_DB") != "" {
|
||||||
databases = []string{os.Getenv("ONLY_DB")}
|
databases = []string{os.Getenv("ONLY_DB")}
|
||||||
}
|
}
|
||||||
//databases := []string{"sqlite"}
|
|
||||||
|
|
||||||
for _, dbt := range databases {
|
for _, dbt := range databases {
|
||||||
|
|
||||||
|
@ -174,39 +172,6 @@ func TestRunAll(t *testing.T) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestVersionCommand(t *testing.T) {
|
|
||||||
c := testcli.Command("statup", "version")
|
|
||||||
c.Run()
|
|
||||||
t.Log(c.Stdout())
|
|
||||||
assert.True(t, c.StdoutContains("Statup v"))
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestHelpCommand(t *testing.T) {
|
|
||||||
c := testcli.Command("statup", "help")
|
|
||||||
c.Run()
|
|
||||||
t.Log(c.Stdout())
|
|
||||||
assert.True(t, c.StdoutContains("statup help - Shows the user basic information about Statup"))
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestExportCommand(t *testing.T) {
|
|
||||||
t.SkipNow()
|
|
||||||
c := testcli.Command("statup", "export")
|
|
||||||
c.Run()
|
|
||||||
t.Log(c.Stdout())
|
|
||||||
assert.True(t, c.StdoutContains("Exporting Static 'index.html' page"))
|
|
||||||
assert.True(t, fileExists(dir+"/cmd/index.html"))
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestAssetsCommand(t *testing.T) {
|
|
||||||
c := testcli.Command("statup", "assets")
|
|
||||||
c.Run()
|
|
||||||
t.Log(c.Stdout())
|
|
||||||
t.Log("Directory for Assets: ", dir)
|
|
||||||
assert.FileExists(t, dir+"/assets/robots.txt")
|
|
||||||
assert.FileExists(t, dir+"/assets/js/main.js")
|
|
||||||
assert.FileExists(t, dir+"/assets/scss/base.scss")
|
|
||||||
}
|
|
||||||
|
|
||||||
func RunMakeDatabaseConfig(t *testing.T, db string) {
|
func RunMakeDatabaseConfig(t *testing.T, db string) {
|
||||||
port := 5432
|
port := 5432
|
||||||
if db == "mysql" {
|
if db == "mysql" {
|
||||||
|
@ -260,7 +225,6 @@ func RunSelectCoreMYQL(t *testing.T, db string) {
|
||||||
var err error
|
var err error
|
||||||
core.CoreApp, err = core.SelectCore()
|
core.CoreApp, err = core.SelectCore()
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
t.Log(core.CoreApp)
|
|
||||||
assert.Equal(t, "Testing "+db, core.CoreApp.Name)
|
assert.Equal(t, "Testing "+db, core.CoreApp.Name)
|
||||||
assert.Equal(t, db, core.CoreApp.DbConnection)
|
assert.Equal(t, db, core.CoreApp.DbConnection)
|
||||||
assert.NotEmpty(t, core.CoreApp.ApiKey)
|
assert.NotEmpty(t, core.CoreApp.ApiKey)
|
||||||
|
|
|
@ -71,3 +71,10 @@ func TestInsertNotifierDB(t *testing.T) {
|
||||||
err := InsertNotifierDB()
|
err := InsertNotifierDB()
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestExportStaticHTML(t *testing.T) {
|
||||||
|
data := ExportIndexHTML()
|
||||||
|
assert.Contains(t, data, "Statup made with ❤️")
|
||||||
|
assert.Contains(t, data, "</body>")
|
||||||
|
assert.Contains(t, data, "</html>")
|
||||||
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func ExportIndexHTML() string {
|
func ExportIndexHTML() string {
|
||||||
|
source.Assets()
|
||||||
CoreApp.UseCdn = true
|
CoreApp.UseCdn = true
|
||||||
//out := index{*CoreApp, CoreApp.Services}
|
//out := index{*CoreApp, CoreApp.Services}
|
||||||
nav, _ := source.TmplBox.String("nav.html")
|
nav, _ := source.TmplBox.String("nav.html")
|
||||||
|
@ -28,6 +29,12 @@ func ExportIndexHTML() string {
|
||||||
"VERSION": func() string {
|
"VERSION": func() string {
|
||||||
return VERSION
|
return VERSION
|
||||||
},
|
},
|
||||||
|
"CoreApp": func() *Core {
|
||||||
|
return CoreApp
|
||||||
|
},
|
||||||
|
"USE_CDN": func() bool {
|
||||||
|
return CoreApp.UseCdn
|
||||||
|
},
|
||||||
"underscore": func(html string) string {
|
"underscore": func(html string) string {
|
||||||
return utils.UnderScoreString(html)
|
return utils.UnderScoreString(html)
|
||||||
},
|
},
|
||||||
|
|
|
@ -66,6 +66,57 @@ func TestCheckTCPService(t *testing.T) {
|
||||||
assert.NotZero(t, service.Latency)
|
assert.NotZero(t, service.Latency)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestServiceOnline24Hours(t *testing.T) {
|
||||||
|
service := SelectService(5)
|
||||||
|
amount := service.Online24()
|
||||||
|
assert.Equal(t, float32(100), amount)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestServiceSmallText(t *testing.T) {
|
||||||
|
service := SelectService(5)
|
||||||
|
text := service.SmallText()
|
||||||
|
assert.Contains(t, text, "Online since")
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestServiceAvgUptime(t *testing.T) {
|
||||||
|
service := SelectService(5)
|
||||||
|
uptime := service.AvgUptime()
|
||||||
|
assert.Equal(t, "100", uptime)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestServiceHits(t *testing.T) {
|
||||||
|
service := SelectService(5)
|
||||||
|
hits, err := service.Hits()
|
||||||
|
assert.Nil(t, err)
|
||||||
|
assert.Equal(t, int(1), len(hits))
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestServiceLimitedHits(t *testing.T) {
|
||||||
|
service := SelectService(5)
|
||||||
|
hits, err := service.LimitedHits()
|
||||||
|
assert.Nil(t, err)
|
||||||
|
assert.Equal(t, int(1), len(hits))
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestServiceTotalHits(t *testing.T) {
|
||||||
|
service := SelectService(5)
|
||||||
|
hits, err := service.TotalHits()
|
||||||
|
assert.Nil(t, err)
|
||||||
|
assert.Equal(t, uint64(0x1), hits)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestServiceSum(t *testing.T) {
|
||||||
|
service := SelectService(5)
|
||||||
|
sum, err := service.Sum()
|
||||||
|
assert.Nil(t, err)
|
||||||
|
assert.NotZero(t, sum)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestCountOnline(t *testing.T) {
|
||||||
|
amount := CountOnline()
|
||||||
|
assert.Equal(t, 2, amount)
|
||||||
|
}
|
||||||
|
|
||||||
func TestCreateService(t *testing.T) {
|
func TestCreateService(t *testing.T) {
|
||||||
s := &types.Service{
|
s := &types.Service{
|
||||||
Name: "Interpol - All The Rage Back Home",
|
Name: "Interpol - All The Rage Back Home",
|
||||||
|
|
|
@ -31,16 +31,68 @@ func TestSelectUser(t *testing.T) {
|
||||||
assert.True(t, user.Admin)
|
assert.True(t, user.Admin)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestSelectUsername(t *testing.T) {
|
||||||
|
user, err := SelectUsername("hunter")
|
||||||
|
assert.Nil(t, err)
|
||||||
|
assert.Equal(t, "test@email.com", user.Email)
|
||||||
|
assert.Equal(t, int64(1), user.Id)
|
||||||
|
assert.True(t, user.Admin)
|
||||||
|
}
|
||||||
|
|
||||||
func TestUpdateUser(t *testing.T) {
|
func TestUpdateUser(t *testing.T) {
|
||||||
user, err := SelectUser(1)
|
user, err := SelectUser(1)
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
|
|
||||||
user.Username = "updated"
|
user.Username = "updated"
|
||||||
|
|
||||||
err = UpdateUser(user)
|
err = UpdateUser(user)
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
|
|
||||||
updatedUser, err := SelectUser(1)
|
updatedUser, err := SelectUser(1)
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
assert.Equal(t, "updated", updatedUser.Username)
|
assert.Equal(t, "updated", updatedUser.Username)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCreateUser2(t *testing.T) {
|
||||||
|
user := &types.User{
|
||||||
|
Username: "hunterlong",
|
||||||
|
Password: "password123",
|
||||||
|
Email: "user@email.com",
|
||||||
|
Admin: true,
|
||||||
|
}
|
||||||
|
userId, err := CreateUser(user)
|
||||||
|
assert.Nil(t, err)
|
||||||
|
assert.NotZero(t, userId)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestSelectAllUsersAgain(t *testing.T) {
|
||||||
|
users, err := SelectAllUsers()
|
||||||
|
assert.Nil(t, err)
|
||||||
|
assert.Equal(t, 2, len(users))
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestAuthUser(t *testing.T) {
|
||||||
|
user, auth := AuthUser("hunterlong", "password123")
|
||||||
|
assert.True(t, auth)
|
||||||
|
assert.NotNil(t, user)
|
||||||
|
assert.Equal(t, "user@email.com", user.Email)
|
||||||
|
assert.Equal(t, int64(2), user.Id)
|
||||||
|
assert.True(t, user.Admin)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestFailedAuthUser(t *testing.T) {
|
||||||
|
user, auth := AuthUser("hunter", "wrongpassword")
|
||||||
|
assert.False(t, auth)
|
||||||
|
assert.Nil(t, user)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestCheckPassword(t *testing.T) {
|
||||||
|
user, err := SelectUser(2)
|
||||||
|
assert.Nil(t, err)
|
||||||
|
pass := CheckHash("password123", user.Password)
|
||||||
|
assert.True(t, pass)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestDeleteUser(t *testing.T) {
|
||||||
|
user, err := SelectUser(2)
|
||||||
|
assert.Nil(t, err)
|
||||||
|
err = DeleteUser(user)
|
||||||
|
assert.Nil(t, err)
|
||||||
|
}
|
||||||
|
|
|
@ -87,6 +87,9 @@ func ExecuteResponse(w http.ResponseWriter, r *http.Request, file string, data i
|
||||||
"VERSION": func() string {
|
"VERSION": func() string {
|
||||||
return core.VERSION
|
return core.VERSION
|
||||||
},
|
},
|
||||||
|
"CoreApp": func() *core.Core {
|
||||||
|
return core.CoreApp
|
||||||
|
},
|
||||||
"USE_CDN": func() bool {
|
"USE_CDN": func() bool {
|
||||||
return core.CoreApp.UseCdn
|
return core.CoreApp.UseCdn
|
||||||
},
|
},
|
||||||
|
|
|
@ -123,8 +123,6 @@ func TestServiceChartHandler(t *testing.T) {
|
||||||
assert.Equal(t, 200, rr.Code)
|
assert.Equal(t, 200, rr.Code)
|
||||||
assert.Contains(t, body, "var ctx_1")
|
assert.Contains(t, body, "var ctx_1")
|
||||||
assert.Contains(t, body, "var ctx_2")
|
assert.Contains(t, body, "var ctx_2")
|
||||||
assert.Contains(t, body, "var ctx_3")
|
|
||||||
assert.Contains(t, body, "var ctx_4")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDashboardHandler(t *testing.T) {
|
func TestDashboardHandler(t *testing.T) {
|
||||||
|
@ -339,7 +337,6 @@ func TestViewHTTPServicesHandler(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestViewTCPServicesHandler(t *testing.T) {
|
func TestViewTCPServicesHandler(t *testing.T) {
|
||||||
t.SkipNow()
|
|
||||||
req, err := http.NewRequest("GET", "/service/7", nil)
|
req, err := http.NewRequest("GET", "/service/7", nil)
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
rr := httptest.NewRecorder()
|
rr := httptest.NewRecorder()
|
||||||
|
@ -357,6 +354,7 @@ func TestServicesDeleteFailuresHandler(t *testing.T) {
|
||||||
rr := httptest.NewRecorder()
|
rr := httptest.NewRecorder()
|
||||||
Router().ServeHTTP(rr, req)
|
Router().ServeHTTP(rr, req)
|
||||||
assert.Equal(t, 200, rr.Code)
|
assert.Equal(t, 200, rr.Code)
|
||||||
|
assert.True(t, IsRouteAuthenticated(req))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestServicesUpdateHandler(t *testing.T) {
|
func TestServicesUpdateHandler(t *testing.T) {
|
||||||
|
@ -379,6 +377,7 @@ func TestServicesUpdateHandler(t *testing.T) {
|
||||||
assert.Equal(t, 200, rr.Code)
|
assert.Equal(t, 200, rr.Code)
|
||||||
assert.Contains(t, body, "<title>Statup | The Bravery - An Honest Mistake Service</title>")
|
assert.Contains(t, body, "<title>Statup | The Bravery - An Honest Mistake Service</title>")
|
||||||
assert.Contains(t, body, "Statup made with ❤️")
|
assert.Contains(t, body, "Statup made with ❤️")
|
||||||
|
assert.True(t, IsRouteAuthenticated(req))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDeleteServiceHandler(t *testing.T) {
|
func TestDeleteServiceHandler(t *testing.T) {
|
||||||
|
@ -390,7 +389,6 @@ func TestDeleteServiceHandler(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestLogsHandler(t *testing.T) {
|
func TestLogsHandler(t *testing.T) {
|
||||||
t.SkipNow()
|
|
||||||
req, err := http.NewRequest("GET", "/logs", nil)
|
req, err := http.NewRequest("GET", "/logs", nil)
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
rr := httptest.NewRecorder()
|
rr := httptest.NewRecorder()
|
||||||
|
@ -402,7 +400,6 @@ func TestLogsHandler(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestLogsLineHandler(t *testing.T) {
|
func TestLogsLineHandler(t *testing.T) {
|
||||||
t.SkipNow()
|
|
||||||
req, err := http.NewRequest("GET", "/logs/line", nil)
|
req, err := http.NewRequest("GET", "/logs/line", nil)
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
rr := httptest.NewRecorder()
|
rr := httptest.NewRecorder()
|
||||||
|
@ -509,6 +506,25 @@ func TestViewNotificationSettingsHandler(t *testing.T) {
|
||||||
assert.True(t, IsRouteAuthenticated(req))
|
assert.True(t, IsRouteAuthenticated(req))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestSaveFooterHandler(t *testing.T) {
|
||||||
|
form := url.Values{}
|
||||||
|
form.Add("footer", "Created by Hunter Long")
|
||||||
|
req, err := http.NewRequest("POST", "/settings", strings.NewReader(form.Encode()))
|
||||||
|
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
||||||
|
assert.Nil(t, err)
|
||||||
|
rr := httptest.NewRecorder()
|
||||||
|
Router().ServeHTTP(rr, req)
|
||||||
|
assert.Equal(t, 200, rr.Code)
|
||||||
|
|
||||||
|
req, err = http.NewRequest("GET", "/", nil)
|
||||||
|
assert.Nil(t, err)
|
||||||
|
rr = httptest.NewRecorder()
|
||||||
|
Router().ServeHTTP(rr, req)
|
||||||
|
body := rr.Body.String()
|
||||||
|
assert.Equal(t, 200, rr.Code)
|
||||||
|
assert.Contains(t, body, "Created by Hunter Long")
|
||||||
|
}
|
||||||
|
|
||||||
func TestError404Handler(t *testing.T) {
|
func TestError404Handler(t *testing.T) {
|
||||||
req, err := http.NewRequest("GET", "/404me", nil)
|
req, err := http.NewRequest("GET", "/404me", nil)
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
package source
|
package source
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/GeertJohan/go.rice"
|
"github.com/GeertJohan/go.rice"
|
||||||
"github.com/hunterlong/statup/utils"
|
"github.com/hunterlong/statup/utils"
|
||||||
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
@ -28,20 +30,53 @@ func Assets() {
|
||||||
|
|
||||||
func CompileSASS(folder string) error {
|
func CompileSASS(folder string) error {
|
||||||
sassBin := os.Getenv("SASS")
|
sassBin := os.Getenv("SASS")
|
||||||
|
if sassBin == "" {
|
||||||
|
return errors.New("missing the SASS executable environment variable")
|
||||||
|
}
|
||||||
|
|
||||||
scssFile := fmt.Sprintf("%v/%v", folder, "assets/scss/base.scss")
|
scssFile := fmt.Sprintf("%v/%v", folder, "assets/scss/base.scss")
|
||||||
baseFile := fmt.Sprintf("%v/%v", folder, "assets/css/base.css")
|
baseFile := fmt.Sprintf("%v/%v", folder, "assets/css/base.css")
|
||||||
|
|
||||||
utils.Log(1, fmt.Sprintf("Compiling SASS %v into %v", scssFile, baseFile))
|
utils.Log(1, fmt.Sprintf("Compiling SASS %v into %v", scssFile, baseFile))
|
||||||
command := fmt.Sprintf("%v %v %v", sassBin, scssFile, baseFile)
|
command := fmt.Sprintf("%v %v %v", sassBin, scssFile, baseFile)
|
||||||
testCmd := exec.Command("bash", "-c", command)
|
|
||||||
out, err := testCmd.Output()
|
utils.Log(1, fmt.Sprintf("Command: sh -c %v", command))
|
||||||
|
|
||||||
|
testCmd := exec.Command("sh", "-c", command)
|
||||||
|
|
||||||
|
var stdout, stderr []byte
|
||||||
|
var errStdout, errStderr error
|
||||||
|
stdoutIn, _ := testCmd.StdoutPipe()
|
||||||
|
stderrIn, _ := testCmd.StderrPipe()
|
||||||
|
testCmd.Start()
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
stdout, errStdout = copyAndCapture(os.Stdout, stdoutIn)
|
||||||
|
}()
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
stderr, errStderr = copyAndCapture(os.Stderr, stderrIn)
|
||||||
|
}()
|
||||||
|
|
||||||
|
err := testCmd.Wait()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.Log(3, fmt.Sprintf("Failed to compile assets with SASS %v", err))
|
utils.Log(3, err)
|
||||||
utils.Log(3, fmt.Sprintf("%v %v %v", sassBin, scssFile, baseFile))
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
utils.Log(1, string(out))
|
|
||||||
|
if errStdout != nil || errStderr != nil {
|
||||||
|
utils.Log(3, fmt.Sprintf("Failed to compile assets with SASS %v", err))
|
||||||
|
return errors.New("failed to capture stdout or stderr")
|
||||||
|
}
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
utils.Log(3, fmt.Sprintf("Failed to compile assets with SASS %v", err))
|
||||||
|
utils.Log(3, fmt.Sprintf("bash -c %v %v %v", sassBin, scssFile, baseFile))
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
outStr, errStr := string(stdout), string(stderr)
|
||||||
|
utils.Log(1, fmt.Sprintf("out: %v | error: %v", outStr, errStr))
|
||||||
utils.Log(1, "SASS Compiling is complete!")
|
utils.Log(1, "SASS Compiling is complete!")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -95,6 +130,7 @@ func CreateAllAssets(folder string) error {
|
||||||
utils.Log(1, "Inserting scss, css, and javascript files into assets folder")
|
utils.Log(1, "Inserting scss, css, and javascript files into assets folder")
|
||||||
CopyToPublic(ScssBox, folder+"/assets/scss", "base.scss")
|
CopyToPublic(ScssBox, folder+"/assets/scss", "base.scss")
|
||||||
CopyToPublic(ScssBox, folder+"/assets/scss", "variables.scss")
|
CopyToPublic(ScssBox, folder+"/assets/scss", "variables.scss")
|
||||||
|
CopyToPublic(ScssBox, folder+"/assets/scss", "mobile.scss")
|
||||||
CopyToPublic(CssBox, folder+"/assets/css", "bootstrap.min.css")
|
CopyToPublic(CssBox, folder+"/assets/css", "bootstrap.min.css")
|
||||||
CopyToPublic(CssBox, folder+"/assets/css", "base.css")
|
CopyToPublic(CssBox, folder+"/assets/css", "base.css")
|
||||||
CopyToPublic(JsBox, folder+"/assets/js", "bootstrap.min.js")
|
CopyToPublic(JsBox, folder+"/assets/js", "bootstrap.min.js")
|
||||||
|
@ -141,3 +177,29 @@ func MakePublicFolder(folder string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func copyAndCapture(w io.Writer, r io.Reader) ([]byte, error) {
|
||||||
|
var out []byte
|
||||||
|
buf := make([]byte, 1024, 1024)
|
||||||
|
for {
|
||||||
|
n, err := r.Read(buf[:])
|
||||||
|
if n > 0 {
|
||||||
|
d := buf[:n]
|
||||||
|
out = append(out, d...)
|
||||||
|
_, err := w.Write(d)
|
||||||
|
if err != nil {
|
||||||
|
return out, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
// Read returns io.EOF at the end of file, which is not an error for us
|
||||||
|
if err == io.EOF {
|
||||||
|
err = nil
|
||||||
|
}
|
||||||
|
return out, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// never reached
|
||||||
|
panic(true)
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
|
@ -25,12 +25,14 @@ func TestCore_UsingAssets(t *testing.T) {
|
||||||
func TestCreateAssets(t *testing.T) {
|
func TestCreateAssets(t *testing.T) {
|
||||||
assert.Nil(t, CreateAllAssets(dir))
|
assert.Nil(t, CreateAllAssets(dir))
|
||||||
assert.True(t, HasAssets(dir))
|
assert.True(t, HasAssets(dir))
|
||||||
|
assert.FileExists(t, "../assets/css/base.css")
|
||||||
|
assert.FileExists(t, "../assets/scss/base.scss")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCompileSASS(t *testing.T) {
|
func TestCompileSASS(t *testing.T) {
|
||||||
t.SkipNow()
|
if os.Getenv("IS_DOCKER") == "true" {
|
||||||
//os.Setenv("SASS", "sass")
|
os.Setenv("SASS", "/usr/local/bin/sass")
|
||||||
os.Setenv("CMD_FILE", dir+"/cmd.sh")
|
}
|
||||||
assert.Nil(t, CompileSASS(dir))
|
assert.Nil(t, CompileSASS(dir))
|
||||||
assert.True(t, HasAssets(dir))
|
assert.True(t, HasAssets(dir))
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
{{ define "footer"}}
|
{{ define "footer"}}
|
||||||
<div class="footer text-center mb-4">
|
<div class="footer text-center mb-4">
|
||||||
{{ if .Core.Footer }}
|
{{ if CoreApp.Footer }}
|
||||||
{{ safe .Core.Footer }}
|
{{ safe CoreApp.Footer }}
|
||||||
{{ end }}
|
{{ else }}
|
||||||
<a href="https://github.com/hunterlong/statup" target="_blank">Statup {{ VERSION }} made with ❤️</a> | <a href="/dashboard">Dashboard</a>
|
<a href="https://github.com/hunterlong/statup" target="_blank">Statup {{VERSION}} made with ❤️</a> | <a href="/dashboard">Dashboard</a>
|
||||||
|
{{ end }}
|
||||||
</div>
|
</div>
|
||||||
{{ end }}
|
{{ end }}
|
|
@ -80,3 +80,12 @@ func DeleteFile(file string) bool {
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func DeleteDirectory(directory string) bool {
|
||||||
|
err := os.RemoveAll(directory)
|
||||||
|
if err != nil {
|
||||||
|
Log(3, err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
|
@ -25,6 +25,10 @@ func TestLog(t *testing.T) {
|
||||||
assert.Nil(t, Log(5, errors.New("this is a 5 level error")))
|
assert.Nil(t, Log(5, errors.New("this is a 5 level error")))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestLogFileCreation(t *testing.T) {
|
||||||
|
assert.FileExists(t, "../logs/statup.log")
|
||||||
|
}
|
||||||
|
|
||||||
func TestDeleteFile(t *testing.T) {
|
func TestDeleteFile(t *testing.T) {
|
||||||
assert.True(t, DeleteFile(Directory+"/logs/statup.log"))
|
assert.True(t, DeleteFile(Directory+"/logs/statup.log"))
|
||||||
}
|
}
|
||||||
|
@ -67,3 +71,7 @@ func TestRandomString(t *testing.T) {
|
||||||
func TestSha256(t *testing.T) {
|
func TestSha256(t *testing.T) {
|
||||||
assert.Equal(t, "dc724af18fbdd4e59189f5fe768a5f8311527050", Sha256([]byte("testing")))
|
assert.Equal(t, "dc724af18fbdd4e59189f5fe768a5f8311527050", Sha256([]byte("testing")))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestDeleteDirectory(t *testing.T) {
|
||||||
|
assert.True(t, DeleteDirectory(Directory+"/logs"))
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue