Skip to content

Commit

Permalink
bee new
Browse files Browse the repository at this point in the history
  • Loading branch information
mef13 committed Apr 13, 2019
1 parent 088ae51 commit 4a925d0
Show file tree
Hide file tree
Showing 6 changed files with 173 additions and 0 deletions.
3 changes: 3 additions & 0 deletions conf/app.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
appname = beego-blankapp
httpport = 8080
runmode = dev
15 changes: 15 additions & 0 deletions controllers/default.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package controllers

import (
"github.com/astaxie/beego"
)

type MainController struct {
beego.Controller
}

func (c *MainController) Get() {
c.Data["Website"] = "beego.me"
c.Data["Email"] = "[email protected]"
c.TplName = "index.tpl"
}
11 changes: 11 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package main

import (
_ "beego-blankapp/routers"
"github.com/astaxie/beego"
)

func main() {
beego.Run()
}

10 changes: 10 additions & 0 deletions routers/router.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package routers

import (
"beego-blankapp/controllers"
"github.com/astaxie/beego"
)

func init() {
beego.Router("/", &controllers.MainController{})
}
39 changes: 39 additions & 0 deletions tests/default_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package test

import (
"net/http"
"net/http/httptest"
"testing"
"runtime"
"path/filepath"
_ "beego-blankapp/routers"

"github.com/astaxie/beego"
. "github.com/smartystreets/goconvey/convey"
)

func init() {
_, file, _, _ := runtime.Caller(0)
apppath, _ := filepath.Abs(filepath.Dir(filepath.Join(file, ".." + string(filepath.Separator))))
beego.TestBeegoInit(apppath)
}


// TestBeego is a sample to run an endpoint test
func TestBeego(t *testing.T) {
r, _ := http.NewRequest("GET", "/", nil)
w := httptest.NewRecorder()
beego.BeeApp.Handlers.ServeHTTP(w, r)

beego.Trace("testing", "TestBeego", "Code[%d]\n%s", w.Code, w.Body.String())

Convey("Subject: Test Station Endpoint\n", t, func() {
Convey("Status Code Should Be 200", func() {
So(w.Code, ShouldEqual, 200)
})
Convey("The Result Should Not Be Empty", func() {
So(w.Body.Len(), ShouldBeGreaterThan, 0)
})
})
}

95 changes: 95 additions & 0 deletions views/index.tpl

Large diffs are not rendered by default.

0 comments on commit 4a925d0

Please sign in to comment.