Skip to content

Commit 93b2567

Browse files
author
anonx
committed
Use files in revel/testdata rather than samples/booking for a fake app test
1 parent ed3ec0f commit 93b2567

File tree

7 files changed

+155
-9
lines changed

7 files changed

+155
-9
lines changed

fakeapp_test.go

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"log"
66
"os"
77
"path"
8-
"path/filepath"
98
"reflect"
109
)
1110

@@ -59,20 +58,14 @@ func (c Static) Serve(prefix, filepath string) Result {
5958
}
6059

6160
func startFakeBookingApp() {
62-
Init("prod", "github.com/revel/samples/booking", "")
61+
Init("prod", "github.com/revel/revel/testdata", "")
6362

6463
// Disable logging.
6564
TRACE = log.New(ioutil.Discard, "", 0)
6665
INFO = TRACE
6766
WARN = TRACE
6867
ERROR = TRACE
6968

70-
runStartupHooks()
71-
72-
MainRouter = NewRouter("")
73-
routesFile, _ := ioutil.ReadFile(filepath.Join(BasePath, "conf", "routes"))
74-
MainRouter.Routes, _ = parseRoutes("", "", string(routesFile), false)
75-
MainRouter.updateTree()
7669
MainTemplateLoader = NewTemplateLoader([]string{ViewsPath, path.Join(RevelPath, "templates")})
7770
MainTemplateLoader.Refresh()
7871

@@ -86,7 +79,7 @@ func startFakeBookingApp() {
8679
Args: []*MethodArg{
8780
{"id", reflect.TypeOf((*int)(nil))},
8881
},
89-
RenderArgNames: map[int][]string{31: []string{"title", "hotel"}},
82+
RenderArgNames: map[int][]string{30: []string{"title", "hotel"}},
9083
},
9184
&MethodType{
9285
Name: "Book",
@@ -107,4 +100,6 @@ func startFakeBookingApp() {
107100
RenderArgNames: map[int][]string{},
108101
},
109102
})
103+
104+
runStartupHooks()
110105
}

testdata/app/views/footer.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
</div>
2+
3+
<div id="footer">
4+
Created with the <a href="http://github.com/revel/revel">Revel framework</a> and really inspirated from the booking sample application provided by <a href="http://www.playframework.org">play framework</a>, which was really inspired by the booking sample application provided by the <a href="http://seamframework.org/">seam framework</a>.
5+
</div>
6+
7+
</body>
8+
</html>

testdata/app/views/header.html

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<!DOCTYPE html>
2+
3+
<html>
4+
<head>
5+
<title>{{.title}}</title>
6+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
7+
<link rel="stylesheet" type="text/css" media="screen" href="/public/css/main.css">
8+
{{range .moreStyles}}
9+
<link rel="stylesheet" type="text/css" href="/public/{{.}}">
10+
{{end}}
11+
<script src="/public/js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
12+
<script src="/public/js/sessvars.js" type="text/javascript" charset="utf-8"></script>
13+
{{range .moreScripts}}
14+
<script src="/public/{{.}}" type="text/javascript" charset="utf-8"></script>
15+
{{end}}
16+
</head>
17+
<body>
18+
19+
<div id="header">
20+
<h1>revel framework booking demo</h1>
21+
{{if .user}}
22+
<div id="options">
23+
Connected as {{.user.Username}}
24+
|
25+
<a href="{{url "Hotels.Index"}}">Search</a>
26+
|
27+
<a href="{{url "Hotels.Settings"}}">Settings</a>
28+
|
29+
<a href="{{url "Application.Logout"}}">Logout</a>
30+
</div>
31+
{{end}}
32+
</div>
33+
34+
<div id="content">
35+
{{if .flash.error}}
36+
<p class="fError">
37+
<strong>{{.flash.error}}</strong>
38+
</p>
39+
{{end}}
40+
{{if .flash.success}}
41+
<p class="fSuccess">
42+
<strong>{{.flash.success}}</strong>
43+
</p>
44+
{{end}}
45+

testdata/app/views/hotels/show.html

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{{template "header.html" .}}
2+
3+
<h1>View hotel</h1>
4+
5+
{{with .hotel}}
6+
<form action="{{url "Hotels.Book" .HotelId}}">
7+
8+
<p>
9+
<strong>Name:</strong> {{.Name}}
10+
</p>
11+
<p>
12+
<strong>Address:</strong> {{.Address}}
13+
</p>
14+
<p>
15+
<strong>City:</strong> {{.City}}
16+
</p>
17+
<p>
18+
<strong>State:</strong> {{.State}}
19+
</p>
20+
<p>
21+
<strong>Zip:</strong> {{.Zip}}
22+
</p>
23+
<p>
24+
<strong>Country:</strong> {{.Country}}
25+
</p>
26+
<p>
27+
<strong>Nightly rate:</strong> {{.Price}}
28+
</p>
29+
30+
<p class="buttons">
31+
<input type="submit" value="Book Hotel">
32+
<a href="{{url "Hotels.Index"}}">Back to search</a>
33+
</p>
34+
</form>
35+
{{end}}
36+
37+
{{template "footer.html" .}}

testdata/conf/app.conf

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Application
2+
app.name=Booking example
3+
app.secret=secret
4+
5+
# Server
6+
http.addr=
7+
http.port=9000
8+
http.ssl=false
9+
http.sslcert=
10+
http.sslkey=
11+
12+
# Logging
13+
log.trace.output = stderr
14+
log.info.output = stderr
15+
log.warn.output = stderr
16+
log.error.output = stderr
17+
18+
log.trace.prefix = "TRACE "
19+
log.info.prefix = "INFO "
20+
log.warn.prefix = "WARN "
21+
log.error.prefix = "ERROR "
22+
23+
db.import = github.com/mattn/go-sqlite3
24+
db.driver = sqlite3
25+
db.spec = :memory:
26+
27+
build.tags=gorp
28+
29+
module.jobs=github.com/revel/modules/jobs
30+
module.static=github.com/revel/modules/static
31+
32+
[dev]
33+
mode.dev=true
34+
watch=true
35+
module.testrunner=github.com/revel/modules/testrunner
36+
37+
[prod]
38+
watch=false
39+
module.testrunner=
40+
41+
log.trace.output = off
42+
log.info.output = off
43+
log.warn.output = stderr
44+
log.error.output = stderr

testdata/conf/routes

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Routes
2+
# This file defines all application routes (Higher priority routes first)
3+
# ~~~~
4+
5+
module:testrunner
6+
7+
GET /hotels Hotels.Index
8+
GET /hotels/:id Hotels.Show
9+
GET /hotels/:id/booking Hotels.Book
10+
11+
# Map static resources from the /app/public folder to the /public path
12+
GET /public/*filepath Static.Serve("public")
13+
GET /favicon.ico Static.Serve("public/img","favicon.png")
14+
15+
# Catch all
16+
* /:controller/:action :controller.:action

testdata/public/js/sessvars.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log('Test file');

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy