Permalink
Browse files

Fix storing and view of report format value

- split var and const blocks to split Status and Format numeration
- change type of Format column in DB
- update HTML template for View page
  • Loading branch information...
ligurio committed Aug 29, 2016
1 parent cb4174e commit 81f8e1632f1d231c0478b9d9d9e40f5a64ff1754
Showing with 8 additions and 5 deletions.
  1. +1 −1 db.go
  2. +5 −2 formats.go
  3. +2 −2 static/templates/view.html
View
2 db.go
@@ -11,7 +11,7 @@ import (
type Report struct {
gorm.Model
- Format Format `db:"format"`
+ Format string `db:"format"`
ReportId string `db:"reportid"`
Filename string `db:"filename"`
Body string `db:"body"`
View
@@ -24,14 +24,15 @@ const (
StatusTodo
StatusXFail
StatusUxSuccess
+)
+const (
FmtSubUnit Format = iota
FmtJUnit
FmtTAP
)
var (
-
// Statuses maps status to its friendly name
Statuses = map[Status]string{
StatusNone: "NONE",
@@ -43,7 +44,9 @@ var (
StatusXFail: "XFAIL",
StatusUxSuccess: "UXSUCCESS",
}
+)
+var (
// Formats maps format to its friendly name
Formats = map[Format]string{
FmtSubUnit: "SubUnit",
@@ -71,7 +74,7 @@ func ReadReport(r io.Reader, name string) (*Report, error) {
if jreport, err := junit.NewParser(r); err == nil {
log.Println("DEBUG: JUnit format detected.")
- //report.Format = FmtJUnit
+ report.Format = Formats[FmtJUnit]
for _, ts := range jreport.Suites {
s := new(Suite)
@@ -6,12 +6,12 @@ <h1>View</h1>
<p>The following is a details of uploaded test report.</p><table class="table table-condensed">
<thead><tr><th>Report ID</th><th>Format</th><th>Created</th><th>Filename</th><th>Hits</th></tr></thead>
<tbody>
-<tr><td>{{.ReportId}}</td><td>FORMAT</td><td>{{.CreatedAt.Format "Jan 02, 2006 15:04:05 UTC"}}</td><td>{{.Filename}}</td><td>{{.Hits}}</td></tr>
+<tr><td>{{.ReportId}}</td><td>{{.Format}}</td><td>{{.CreatedAt.Format "Jan 02, 2006 15:04:05 UTC"}}</td><td>{{.Filename}}</td><td>{{.Hits}}</td></tr>
</tbody>
</table>
<pre>
-<code class="FORMAT">
+<code class="{{.Format}}">
{{.Body}}
</code>
</pre>

0 comments on commit 81f8e16

Please sign in to comment.