Skip to content

Commit 9185d0b

Browse files
committed
go-aah/aah#156 added testdata and initial test case
1 parent 2a1f540 commit 9185d0b

25 files changed

+1467
-0
lines changed

testdata/vfstest/.gitignore

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# aah application - .gitignore
2+
3+
aah.go
4+
*.pid
5+
build/
6+
vendor/*/
7+
8+
# Compiled Object files, Static and Dynamic libs (Shared Objects)
9+
*.o
10+
*.a
11+
*.so
12+
13+
# Folders
14+
_obj
15+
_test
16+
17+
# Architecture specific extensions/prefixes
18+
*.[568vq]
19+
[568vq].out
20+
21+
*.cgo1.go
22+
*.cgo2.c
23+
_cgo_defun.c
24+
_cgo_gotypes.go
25+
_cgo_export.*
26+
27+
_testmain.go
28+
29+
*.exe
30+
*.test
31+
*.prof

testdata/vfstest/aah.project

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
##############################################################
2+
# vfstest - aah framework project
3+
#
4+
# Note: Add it to version control
5+
##############################################################
6+
7+
# Build section is used during aah application compile and build command.
8+
build {
9+
# Application binary name
10+
# Default value is `name` attribute value from `aah.conf`
11+
#binary_name = "vfstest"
12+
13+
# Used as fallback if
14+
# - `git commit sha` or
15+
# - `AAH_APP_VERSION` environment value is not available.
16+
version = "0.0.1"
17+
18+
# If application is missing any dependencies in `build import path`
19+
# during a compile and build, aah CLI will try to get dependencies
20+
# using 'go get <package>'.
21+
# Default value is `true`.
22+
#dep_get = true
23+
24+
flags = ["-i"]
25+
26+
ldflags = ""
27+
28+
tags = ""
29+
30+
# AST excludes is used for `aah.Context` inspection and generating aah
31+
# application main Go file. Valid exclude patterns
32+
# refer: https://golang.org/pkg/path/filepath/#Match
33+
ast_excludes = ["*_test.go", ".*", "*.bak", "*.tmp", "vendor"]
34+
35+
# Packing excludes is used to exclude file/directory during aah application
36+
# build archive. Valid exclude patterns
37+
# refer: https://golang.org/pkg/path/filepath/#Match
38+
excludes = ["*.go", "*_test.go", ".*", "*.bak", "*.tmp", "vendor", "app", "build", "tests", "logs"]
39+
}
40+
41+
# Logger configuration for aah CLI tool.
42+
log {
43+
# Log level
44+
# Default value is `info`.
45+
#level = "info"
46+
47+
# Log colored output
48+
# Default value is `true`.
49+
#color = false
50+
}
51+
52+
# Hot-Reload is development purpose to help developer.
53+
# Read more about implementation here - https://aahframework.org/issues/4
54+
#
55+
# NOTE: Do not use hot-reload feature for production purpose, it's not recommended.
56+
hot_reload {
57+
# Default value is `true`.
58+
enable = true
59+
60+
# Watch configuration - files/directories exclusion list.
61+
watch {
62+
# Note: static directory not required to be monitored, since server delivers
63+
# up-to-date file on environment profile `dev`.
64+
dir_excludes = [".*"]
65+
66+
file_excludes = [".*", "_test.go", "LICENSE", "README.md"]
67+
}
68+
}
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package controllers
2+
3+
import (
4+
"aahframework.org/aah.v0"
5+
6+
"vfstest/app/models"
7+
)
8+
9+
// AppController struct application controller
10+
type AppController struct {
11+
*aah.Context
12+
}
13+
14+
// Index method is application home page.
15+
func (a *AppController) Index() {
16+
data := aah.Data{
17+
"Greet": models.Greet{
18+
Message: "Welcome to aah framework - Web Application",
19+
},
20+
}
21+
22+
a.Reply().Ok().HTML(data)
23+
}

testdata/vfstest/app/init.go

+136
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
// aah application initialization - configuration, server extensions, middleware's, etc.
2+
// Customize it per your application needs.
3+
4+
package main
5+
6+
import (
7+
8+
"aahframework.org/aah.v0"
9+
10+
// Registering HTML minifier for web application
11+
_ "github.com/aah-cb/minify"
12+
)
13+
14+
func init() {
15+
16+
//‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
17+
// Server Extensions
18+
// Doc: https://docs.aahframework.org/server-extension.html
19+
//
20+
// Best Practice: Define a function with meaningful name in a package and
21+
// register it here. Extensions function name gets logged in the log,
22+
// its very helpful to have meaningful log information.
23+
//
24+
// Such as:
25+
// - Dedicated package for config loading
26+
// - Dedicated package for datasource connections
27+
// - etc
28+
//__________________________________________________________________________
29+
30+
// Event: OnInit
31+
//
32+
// Published right after the `aah.AppConfig()` is loaded.
33+
//
34+
// aah.OnInit(config.LoadRemote)
35+
36+
// Event: OnStart
37+
//
38+
// Published right before the start of aah server.
39+
//
40+
// aah.OnStart(db.Connect)
41+
// aah.OnStart(cache.Load)
42+
aah.OnStart(SubscribeHTTPEvents)
43+
44+
// Event: OnShutdown
45+
//
46+
// Published on receiving OS Signals `SIGINT` or `SIGTERM`.
47+
//
48+
// aah.OnShutdown(cache.Flush)
49+
// aah.OnShutdown(db.Disconnect)
50+
51+
//‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
52+
// Middleware's
53+
// Doc: https://docs.aahframework.org/middleware.html
54+
//
55+
// Executed in the order they are defined. It is recommended; NOT to change
56+
// the order of pre-defined aah framework middleware's.
57+
//__________________________________________________________________________
58+
aah.Middlewares(
59+
aah.RouteMiddleware,
60+
aah.CORSMiddleware,
61+
aah.BindMiddleware,
62+
aah.AntiCSRFMiddleware,
63+
aah.AuthcAuthzMiddleware,
64+
65+
//
66+
// NOTE: Register your Custom middleware's right here
67+
//
68+
69+
aah.ActionMiddleware,
70+
)
71+
72+
//‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
73+
// Add Application Error Handler
74+
// Doc: https://docs.aahframework.org/error-handling.html
75+
//__________________________________________________________________________
76+
// aah.SetErrorHandler(AppErrorHandler)
77+
78+
//‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
79+
// Add Custom Template Functions
80+
// Doc: https://docs.aahframework.org/template-funcs.html
81+
//__________________________________________________________________________
82+
// aah.AddTemplateFunc(template.FuncMap{
83+
// // ...
84+
// })
85+
86+
//‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
87+
// Add Custom Session Store
88+
// Doc: https://docs.aahframework.org/session.html
89+
//__________________________________________________________________________
90+
// aah.AddSessionStore("redis", &RedisSessionStore{})
91+
92+
//‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
93+
// Add Custom value Parser
94+
// Doc: https://docs.aahframework.org/request-parameters-auto-bind.html
95+
//__________________________________________________________________________
96+
// if err := aah.AddValueParser(reflect.TypeOf(CustomType{}), customParser); err != nil {
97+
// log.Error(err)
98+
// }
99+
100+
//‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
101+
// Add Custom Validation Functions
102+
// Doc: https://godoc.org/gopkg.in/go-playground/validator.v9
103+
//__________________________________________________________________________
104+
// Obtain aah validator instance, then add yours
105+
// validator := aah.Validator()
106+
//
107+
// // Add your validation funcs
108+
109+
}
110+
111+
//‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
112+
// HTTP Events
113+
//
114+
// Subscribing HTTP events on app start.
115+
//__________________________________________________________________________
116+
117+
func SubscribeHTTPEvents(_ *aah.Event) {
118+
// he := aah.AppHTTPEngine()
119+
120+
// Event: OnRequest
121+
// he.OnRequest(myserverext.OnRequest)
122+
123+
// Event: OnPreReply
124+
// he.OnPreReply(myserverext.OnPreReply)
125+
126+
// Event: OnPostReply
127+
// he.OnPostReply(myserverext.OnPostReply)
128+
129+
// Event: OnPreAuth
130+
// he.OnPreAuth(myserverext.OnPreAuth)
131+
132+
// Event: OnPostAuth
133+
// Published right after the successful Authentication
134+
// he.OnPostAuth(myserverext.PostAuthEvent)
135+
}
136+

testdata/vfstest/app/models/greet.go

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package models
2+
3+
// Greet holds the greeting message.
4+
type Greet struct {
5+
Message string `json:"message"`
6+
}

0 commit comments

Comments
 (0)