func TestSpec(t *testing.T) { Convey("UserRegister", t, func() { var agoutiDriver *agouti.WebDriver var page *agouti.Page session, _ := mgo.Dial("localhost") session.DB("TESTGoNuts").DropDatabase() agoutiDriver = agouti.PhantomJS() So(agoutiDriver.Start(), ShouldBeNil) log.Println("Starting") go StartMyApp(3232, "TESTGoNuts") var err error page, err = agoutiDriver.NewPage(agouti.Browser("chrome")) So(err, ShouldBeNil) Convey("User Registration page", func() { Convey("when the user registration is reached", func() { Convey("should see the page", func() { So(page.Navigate("http://localhost:3232"), ShouldBeNil) url, _ := page.URL() So(url, ShouldEqual, "http://localhost:3232/") }) }) }) Reset(func() { So(page.Destroy(), ShouldBeNil) So(agoutiDriver.Stop(), ShouldBeNil) }) }) }
var _ = BeforeSuite(func() { var err error executablePath, err = gexec.Build("github.com/craigfurman/woodhouse-ci") Expect(err).NotTo(HaveOccurred()) if os.Getenv("HEADLESS") == "true" { agoutiDriver = agouti.PhantomJS() } else { agoutiDriver = agouti.ChromeDriver() } Expect(agoutiDriver.Start()).To(Succeed()) }) var _ = AfterSuite(func() { Expect(agoutiDriver.Stop()).To(Succeed()) gexec.CleanupBuildArtifacts() }) var _ = BeforeEach(func() { cwd, err := os.Getwd() Expect(err).NotTo(HaveOccurred()) storeDir := filepath.Join(cwd, "..", "db") os.Remove(filepath.Join(storeDir, "sqlite", "store.db")) buildsDir, err = ioutil.TempDir("", "integration-builds") Expect(err).NotTo(HaveOccurred()) runningExecutable, err = gexec.Start(exec.Command( executablePath, "-port=3001",
testCASServer, err = cas.NewCASServer(testCASConfig) if err != nil { log.Fatalf("Failed to generate setup cas server, err: %v", err) } testCASServer.SetupDb() // Setup http test server testHTTPServer = httptest.NewTLSServer(testCASServer.ServeMux) // Load database fixtures testCASServer.Db.LoadJSONFixture( testCASServer.Db.GetDbName(), testCASServer.Db.GetServicesTableName(), "../../fixtures/services.json", ) testCASServer.Db.LoadJSONFixture( testCASServer.Db.GetDbName(), testCASServer.Db.GetUsersTableName(), "../../fixtures/users.json", ) Expect(agoutiDriver.Start()).To(Succeed()) }) var _ = AfterSuite(func() { testHTTPServer.Close() testCASServer.TeardownDb() agoutiDriver.Stop() })