Skip to content

Commit

Permalink
Merge pull request #10 from hunterlong/dev
Browse files Browse the repository at this point in the history
CLI test plugin tool updates
  • Loading branch information
hunterlong committed Jul 4, 2018
2 parents b920ba5 + 76c42e1 commit e11a9c7
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ services:

env:
global:
- VERSION=0.29.3
- VERSION=0.29.4
- DB_HOST=localhost
- DB_USER=travis
- DB_PASS=
Expand Down
17 changes: 3 additions & 14 deletions .travis/deploy.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
#!/usr/bin/env bash

# update homebrew to newest version by building on travis
body='{
"request": {
"branch":"master"
}
}'
body='{ "request": { "branch": "master", "config": { "env": { "VERSION": "'$VERSION'" } } } }'

curl -s -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
Expand All @@ -14,18 +11,10 @@ curl -s -X POST \
-d "$body" \
https://api.travis-ci.com/repo/hunterlong%2Fstatup-testing/requests


#git clone https://$GH_USER:$GH_TOKEN@github.com/hunterlong/homebrew-statup.git
#cd homebrew-statup
#
#./build.sh
#cd ../

#docker login -u $DOCKER_USER -p $DOCKER_PASS $DOCKER_URL
#docker build -t $DOCKER_URL/hunterlong/statup .
#docker push $DOCKER_URL/hunterlong/statup

if [ "$TRAVIS_BRANCH" != "master" ]
then
curl -X POST $DOCKER > /dev/null
fi
curl -H "Content-Type: application/json" --data '{"source_type": "Branch", "source_name": "'"$TRAVIS_BRANCH"'"}' -X POST $DOCKER > /dev/null
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM alpine:latest

ENV VERSION=v0.29.3
ENV VERSION=v0.29.4

RUN apk --no-cache add libstdc++ ca-certificates
RUN wget -q https://github.com/hunterlong/statup/releases/download/$VERSION/statup-linux-alpine.tar.gz && \
Expand Down
57 changes: 38 additions & 19 deletions cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ import (
"upper.io/db.v3/sqlite"
)

const (
BRAKER = "=============================================================================="
POINT = " "
)

func CatchCLI(args []string) {
switch args[1] {
case "version":
Expand Down Expand Up @@ -95,13 +100,11 @@ func HelpEcho() {
fmt.Printf("Commands:\n")
fmt.Println(" statup - Main command to run Statup server")
fmt.Println(" statup version - Returns the current version of Statup")
fmt.Println(" statup run - Check all service 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 assets - Export all assets used locally to be edited.")
fmt.Println(" statup assets - Dump all assets used locally to be edited.")
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(" to Github Pages or your own FTP server. Export will")
fmt.Println(" create 'index.html' in the current directory.")
fmt.Println(" statup update - Attempts to update to the latest version")
fmt.Println(" statup help - Shows the user basic information about Statup")
fmt.Println("Give Statup a Star at https://github.com/hunterlong/statup")
Expand All @@ -112,14 +115,16 @@ func TestPlugin(plug plugin.PluginActions) {
defer utils.DeleteFile("./.plugin_test.db")
core.CoreApp.AllPlugins = []plugin.PluginActions{plug}
info := plug.GetInfo()
utils.Log(1, "=======================================================================")
utils.Log(1, fmt.Sprintf(" Plugin Name: %v", info.Name))
utils.Log(1, fmt.Sprintf(" Plugin Description: %v", info.Description))
utils.Log(1, fmt.Sprintf(" Plugin Routes: %v", len(plug.Routes())))
fmt.Printf("\n" + BRAKER + "\n")
fmt.Printf(" Plugin Name: %v\n", info.Name)
fmt.Printf(" Plugin Description: %v\n", info.Description)
fmt.Printf(" Plugin Routes: %v\n", len(plug.Routes()))
for k, r := range plug.Routes() {
utils.Log(1, fmt.Sprintf(" - Route %v - (%v) /%v", k+1, r.Method, r.URL))
fmt.Printf(" - Route %v - (%v) /%v \n", k+1, r.Method, r.URL)
}

fmt.Printf("\n" + BRAKER)

fakeSrv := &core.Service{
Id: 56,
Name: "Test Plugin Service",
Expand Down Expand Up @@ -147,7 +152,7 @@ func TestPlugin(plug plugin.PluginActions) {
CreatedAt: time.Now(),
}

utils.Log(1, fmt.Sprintf("Creating a SQLite database for testing, will be deleted automatically..."))
fmt.Println("\nCreating a SQLite database for testing, will be deleted automatically...")
sqlFake := sqlite.ConnectionURL{
Database: "./.plugin_test.db",
}
Expand All @@ -163,23 +168,37 @@ func TestPlugin(plug plugin.PluginActions) {
utils.Log(2, err)
}
}
utils.Log(1, fmt.Sprintf("Finished creating Test SQLite database, sending events."))
fmt.Println("Finished creating Test SQLite database, sending events.")

utils.Log(1, "======> Sending 'OnLoad(sqlbuilder.Database)'")
fmt.Println("\n" + BRAKER)
fmt.Println(POINT + "Sending 'OnLoad(sqlbuilder.Database)'")
core.OnLoad(fakeDb)
utils.Log(1, "======> Sending 'OnSuccess(Service)'")
fmt.Println("\n" + BRAKER)
fmt.Println(POINT + "Sending 'OnSuccess(Service)'")
core.OnSuccess(fakeSrv)
utils.Log(1, "======> Sending 'OnFailure(Service, FailureData)'")
fmt.Println("\n" + BRAKER)
fmt.Println(POINT + "Sending 'OnFailure(Service, FailureData)'")
core.OnFailure(fakeSrv, fakeFailD)
utils.Log(1, "======> Sending 'OnSettingsSaved(Core)'")
fmt.Println("\n" + BRAKER)
fmt.Println(POINT + "Sending 'OnSettingsSaved(Core)'")
fmt.Println(BRAKER)
core.OnSettingsSaved(fakeCore)
utils.Log(1, "======> Sending 'OnNewService(Service)'")
fmt.Println("\n" + BRAKER)
fmt.Println(POINT + "Sending 'OnNewService(Service)'")
core.OnNewService(fakeSrv)
utils.Log(1, "======> Sending 'OnNewUser(User)'")
fmt.Println("\n" + BRAKER)
fmt.Println(POINT + "Sending 'OnNewUser(User)'")
core.OnNewUser(fakeUser)
utils.Log(1, "======> Sending 'OnUpdateService(Service)'")
fmt.Println("\n" + BRAKER)
fmt.Println(POINT + "Sending 'OnUpdateService(Service)'")
core.OnUpdateService(fakeSrv)
utils.Log(1, "======> Sending 'OnDeletedService(Service)'")
fmt.Println("\n" + BRAKER)
fmt.Println(POINT + "Sending 'OnDeletedService(Service)'")
core.OnDeletedService(fakeSrv)
fmt.Println("\n" + BRAKER)

}

func FakeSeed() {

}

0 comments on commit e11a9c7

Please sign in to comment.