-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from joegasewicz/Tests_#3
Tests #3
- Loading branch information
Showing
10 changed files
with
330 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package gomek |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package gomek |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package gomek | ||
|
||
import "testing" | ||
|
||
func TestLogging(t *testing.T) { | ||
|
||
} | ||
|
||
func TestAuthorize(t *testing.T) { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package gomek | ||
|
||
import "testing" | ||
|
||
func TestTemplate_Run(t *testing.T) { | ||
template := Template{base: []string{"base.html"}} | ||
routeTemplates := []string{"/index.gohtml", "/news.gohtml"} | ||
result := template.Run(routeTemplates...) | ||
expected := []string{"base.html", "/index.gohtml", "/news.gohtml"} | ||
for i, _ := range result { | ||
if result[i] != expected[i] { | ||
t.Errorf("expected %v got %v", result[i], expected[i]) | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package gomek | ||
|
||
import "net/http" | ||
|
||
// CreateTestHandler this function provides an easy way to access the | ||
// `http.HandlerFunc` func. Testing gomek views is thus the same as testing | ||
// any regular HandlerFunc handlers. | ||
// | ||
// c := Config{} | ||
// mockApp := NewTestApp(c) | ||
// mockApp.Route("/blogs").Methods("POST").Resource(&Notice{}) | ||
// mockApp.Start() | ||
// | ||
// notice := Notice{} | ||
// | ||
// handler := CreateTestHandler(mockApp, notice.Post) | ||
// | ||
// req := httptest.NewRequest(http.MethodPost, "/blogs", nil) | ||
// w := httptest.NewRecorder() | ||
// handler(w, req) // regular HandlerFunc | ||
// resp := w.Result() | ||
// | ||
// defer resp.Body.Close() | ||
// data, err := io.ReadAll(resp.Body) | ||
// if err != nil { | ||
// t.Errorf("Error: %v", err) | ||
// } | ||
// expected := `{"name":"Joe"}` | ||
// if string(data) != expected { | ||
// t.Errorf("Expected %s got '%v'", expected, string(data)) | ||
func CreateTestHandler(testApp IApp, view CurrentView) http.HandlerFunc { | ||
v := testApp.GetView() | ||
var templates []string | ||
return v.handleFuncWrapper(templates, testApp.GetConfig(), *testApp.GetView(), view) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package gomek |
Oops, something went wrong.