CLI test plugin tool updates

pull/10/head
Hunter Long 2018-07-04 14:03:11 -07:00
parent b920ba56c3
commit 76c42e16ef
4 changed files with 43 additions and 35 deletions

View File

@ -18,7 +18,7 @@ services:
env: env:
global: global:
- VERSION=0.29.3 - VERSION=0.29.4
- DB_HOST=localhost - DB_HOST=localhost
- DB_USER=travis - DB_USER=travis
- DB_PASS= - DB_PASS=

View File

@ -1,11 +1,8 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# update homebrew to newest version by building on travis # update homebrew to newest version by building on travis
body='{ body='{ "request": { "branch": "master", "config": { "env": { "VERSION": "'$VERSION'" } } } }'
"request": {
"branch":"master"
}
}'
curl -s -X POST \ curl -s -X POST \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-H "Accept: application/json" \ -H "Accept: application/json" \
@ -14,18 +11,10 @@ curl -s -X POST \
-d "$body" \ -d "$body" \
https://api.travis-ci.com/repo/hunterlong%2Fstatup-testing/requests https://api.travis-ci.com/repo/hunterlong%2Fstatup-testing/requests
#git clone https://$GH_USER:$GH_TOKEN@github.com/hunterlong/homebrew-statup.git #git clone https://$GH_USER:$GH_TOKEN@github.com/hunterlong/homebrew-statup.git
#cd homebrew-statup #cd homebrew-statup
# #
#./build.sh #./build.sh
#cd ../ #cd ../
#docker login -u $DOCKER_USER -p $DOCKER_PASS $DOCKER_URL curl -H "Content-Type: application/json" --data '{"source_type": "Branch", "source_name": "'"$TRAVIS_BRANCH"'"}' -X POST $DOCKER > /dev/null
#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

View File

@ -1,6 +1,6 @@
FROM alpine:latest FROM alpine:latest
ENV VERSION=v0.29.3 ENV VERSION=v0.29.4
RUN apk --no-cache add libstdc++ ca-certificates RUN apk --no-cache add libstdc++ ca-certificates
RUN wget -q https://github.com/hunterlong/statup/releases/download/$VERSION/statup-linux-alpine.tar.gz && \ RUN wget -q https://github.com/hunterlong/statup/releases/download/$VERSION/statup-linux-alpine.tar.gz && \

57
cli.go
View File

@ -11,6 +11,11 @@ import (
"upper.io/db.v3/sqlite" "upper.io/db.v3/sqlite"
) )
const (
BRAKER = "=============================================================================="
POINT = " "
)
func CatchCLI(args []string) { func CatchCLI(args []string) {
switch args[1] { switch args[1] {
case "version": case "version":
@ -95,13 +100,11 @@ func HelpEcho() {
fmt.Printf("Commands:\n") fmt.Printf("Commands:\n")
fmt.Println(" statup - Main command to run Statup server") fmt.Println(" statup - Main command to run Statup server")
fmt.Println(" statup version - Returns the current version of Statup") 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 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 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(" 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 update - Attempts to update to the latest version")
fmt.Println(" statup help - Shows the user basic information about Statup") fmt.Println(" statup help - Shows the user basic information about Statup")
fmt.Println("Give Statup a Star at https://github.com/hunterlong/statup") fmt.Println("Give Statup a Star at https://github.com/hunterlong/statup")
@ -112,14 +115,16 @@ func TestPlugin(plug plugin.PluginActions) {
defer utils.DeleteFile("./.plugin_test.db") defer utils.DeleteFile("./.plugin_test.db")
core.CoreApp.AllPlugins = []plugin.PluginActions{plug} core.CoreApp.AllPlugins = []plugin.PluginActions{plug}
info := plug.GetInfo() info := plug.GetInfo()
utils.Log(1, "=======================================================================") fmt.Printf("\n" + BRAKER + "\n")
utils.Log(1, fmt.Sprintf(" Plugin Name: %v", info.Name)) fmt.Printf(" Plugin Name: %v\n", info.Name)
utils.Log(1, fmt.Sprintf(" Plugin Description: %v", info.Description)) fmt.Printf(" Plugin Description: %v\n", info.Description)
utils.Log(1, fmt.Sprintf(" Plugin Routes: %v", len(plug.Routes()))) fmt.Printf(" Plugin Routes: %v\n", len(plug.Routes()))
for k, r := range 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{ fakeSrv := &core.Service{
Id: 56, Id: 56,
Name: "Test Plugin Service", Name: "Test Plugin Service",
@ -147,7 +152,7 @@ func TestPlugin(plug plugin.PluginActions) {
CreatedAt: time.Now(), 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{ sqlFake := sqlite.ConnectionURL{
Database: "./.plugin_test.db", Database: "./.plugin_test.db",
} }
@ -163,23 +168,37 @@ func TestPlugin(plug plugin.PluginActions) {
utils.Log(2, err) 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) core.OnLoad(fakeDb)
utils.Log(1, "======> Sending 'OnSuccess(Service)'") fmt.Println("\n" + BRAKER)
fmt.Println(POINT + "Sending 'OnSuccess(Service)'")
core.OnSuccess(fakeSrv) 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) 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) core.OnSettingsSaved(fakeCore)
utils.Log(1, "======> Sending 'OnNewService(Service)'") fmt.Println("\n" + BRAKER)
fmt.Println(POINT + "Sending 'OnNewService(Service)'")
core.OnNewService(fakeSrv) core.OnNewService(fakeSrv)
utils.Log(1, "======> Sending 'OnNewUser(User)'") fmt.Println("\n" + BRAKER)
fmt.Println(POINT + "Sending 'OnNewUser(User)'")
core.OnNewUser(fakeUser) core.OnNewUser(fakeUser)
utils.Log(1, "======> Sending 'OnUpdateService(Service)'") fmt.Println("\n" + BRAKER)
fmt.Println(POINT + "Sending 'OnUpdateService(Service)'")
core.OnUpdateService(fakeSrv) core.OnUpdateService(fakeSrv)
utils.Log(1, "======> Sending 'OnDeletedService(Service)'") fmt.Println("\n" + BRAKER)
fmt.Println(POINT + "Sending 'OnDeletedService(Service)'")
core.OnDeletedService(fakeSrv) core.OnDeletedService(fakeSrv)
fmt.Println("\n" + BRAKER)
}
func FakeSeed() {
} }