init
This commit is contained in:
commit
0a0a60da6c
3
conf/app.conf
Normal file
3
conf/app.conf
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
appname = devops
|
||||||
|
httpport = 8080
|
||||||
|
runmode = dev
|
15
controllers/default.go
Normal file
15
controllers/default.go
Normal file
@ -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"] = "astaxie@gmail.com"
|
||||||
|
c.TplName = "index.tpl"
|
||||||
|
}
|
6
go.mod
Normal file
6
go.mod
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
module go_ops
|
||||||
|
|
||||||
|
go 1.15
|
||||||
|
|
||||||
|
require github.com/astaxie/beego v1.12.1
|
||||||
|
require github.com/smartystreets/goconvey v1.6.4
|
11
main.go
Normal file
11
main.go
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
_ "devops/routers"
|
||||||
|
"github.com/astaxie/beego"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
beego.Run()
|
||||||
|
}
|
||||||
|
|
10
routers/router.go
Normal file
10
routers/router.go
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
package routers
|
||||||
|
|
||||||
|
import (
|
||||||
|
"devops/controllers"
|
||||||
|
"github.com/astaxie/beego"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
beego.Router("/", &controllers.MainController{})
|
||||||
|
}
|
1
static/js/reload.min.js
vendored
Normal file
1
static/js/reload.min.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
function b(a){var c=new WebSocket(a);c.onclose=function(){setTimeout(function(){b(a)},2E3)};c.onmessage=function(){location.reload()}}try{if(window.WebSocket)try{b("ws://localhost:12450/reload")}catch(a){console.error(a)}else console.log("Your browser does not support WebSockets.")}catch(a){console.error("Exception during connecting to Reload:",a)};
|
39
tests/default_test.go
Normal file
39
tests/default_test.go
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
"net/http/httptest"
|
||||||
|
"testing"
|
||||||
|
"runtime"
|
||||||
|
"path/filepath"
|
||||||
|
_ "devops/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
views/index.tpl
Normal file
95
views/index.tpl
Normal file
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user