Skip to content

Instantly share code, notes, and snippets.

@npkumar
Last active January 28, 2016 21:09
Show Gist options
  • Save npkumar/0ee82ebb832759c35989 to your computer and use it in GitHub Desktop.
Save npkumar/0ee82ebb832759c35989 to your computer and use it in GitHub Desktop.
test for arrowcloud_deploy
--- a/src/cmd/arrowcloud_deploy/arrowcloud_deploy.go
+++ b/src/cmd/arrowcloud_deploy/arrowcloud_deploy.go
@@ -4,6 +4,7 @@ package main
import (
"cmd/precheck"
+ "cmd/test"
"flag"
"fmt"
log "github.com/Sirupsen/logrus"
@@ -22,6 +23,7 @@ import (
var (
configFile = ""
forceUpdate = false
+ postTestOnly = false
preCheckOnly = false
)
@@ -29,6 +31,7 @@ func init() {
flag.StringVar(&configFile, "config-file", "", "the arrowcloud_deploy config file")
flag.BoolVar(&forceUpdate, "force", false, "force updating nodes if they have different env settings than specified")
flag.BoolVar(&preCheckOnly, "precheck", false, "run pre-check only")
+ flag.BoolVar(&postTestOnly, "test", false, "run post-test only")
log.SetLevel(log.DebugLevel)
f, err := log_utility.CreateLogFile("deployment")
@@ -136,6 +139,15 @@ func main() {
}
}
+ // run only tests post deployment
+ err = test.Exec(configJson)
+ if err != nil {
+ log.Fatal(err)
+ }
+ if postTestOnly {
+ return
+ }
+
// check networking of hosts first
err = precheck.Exec(configJson)
if err != nil {
package test
import (
"testing"
logger "github.com/Sirupsen/logrus"
"github.com/jeffail/gabs"
// "github.com/verdverm/frisby"
. "github.com/franela/goblin"
//. "github.com/onsi/gomega"
)
func Test(t *testing.T) {
g := Goblin(t)
g.Describe("Numbers", func() {
g.It("Should add two numbers ", func() {
g.Assert(1+1).Equal(2)
})
g.It("Should match equal numbers", func() {
g.Assert(2).Equal(4)
})
g.It("Should substract two numbers")
})
}
func Exec(configJson *gabs.Container) error {
logger.Info("Running tests post deployment...\n")
return nil
}
/*
import (
"net/http"
"testing"
// "github.com/emicklei/forest"
)
// setup a shared client to your API
var chatter = forest.NewClient("https://preprod-api.cloud.appctest.com", new(http.Client))
func init(){
}
func TestGetMessages(t *testing.T) {
r := chatter.GET(t, forest.Path("v1/users/show.json").Query("_session_id","CJhilJwTUFchsyiv9BUvEN9DO1U").Query("user_id","56a953ae48826608f03fe226").Query("key","9B5wdvyxjoU4nIzTkWuWgwyHTgKviKmv"))
forest.ExpectStatus(t,r,200)
// forest.ExpectJSONArray(t,r,func(messages []interface{}){
//
// // in the callback you can validate the response structure
// if len(messages) == 0 {
// t.Error("expected messages, got none")
// }
// })
}
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment