package main import ( "io/ioutil" "net/http" "net/http/httptest" "os" "testing" "github.com/stretchr/testify/assert" "github.com/yosssi/gohtml" ) // TempFile persists contents and returns the path and a clean func func TempFile(t *testing.T, contents string) (path string, clean func()) { content := []byte(contents) tmpfile, err := ioutil.TempFile("", "sally-tmp") if err != nil { t.Fatal("Unable to create tmpfile", err) } if _, err := tmpfile.Write(content); err != nil { t.Fatal("Unable to write tmpfile", err) } if err := tmpfile.Close(); err != nil { t.Fatal("Unable to close tmpfile", err) } return tmpfile.Name(), func() { _ = os.Remove(tmpfile.Name()) } } // CreateHandlerFromYAML builds the Sally handler from a yaml config string func CreateHandlerFromYAML(t *testing.T, content string) (handler http.Handler, clean func()) { path, clean := TempFile(t, content) config, err := Parse(path) if err != nil { t.Fatalf("Unable to parse %s: %v", path, err) } return CreateHandler(config), clean } // CallAndRecord makes a GET request to the Sally handler and returns a response recorder func CallAndRecord(t *testing.T, config string, uri string) *httptest.ResponseRecorder { handler, clean := CreateHandlerFromYAML(t, config) defer clean() req, err := http.NewRequest("GET", uri, nil) if err != nil { t.Fatalf("Unable to create request to %s: %v", uri, err) } rr := httptest.NewRecorder() handler.ServeHTTP(rr, req) return rr } // AssertResponse normalizes and asserts the body from rr against want func AssertResponse(t *testing.T, rr *httptest.ResponseRecorder, code int, want string) { assert.Equal(t, rr.Code, code) assert.Equal(t, gohtml.Format(want), gohtml.Format(rr.Body.String())) } it' value='search'/>
path: root/.github (unfollow)
AgeCommit message (Expand)AuthorFilesLines
2024-08-28Fix incorrect key for `child_database` block objectfix-block-child-db-keyGravatar Anshul Gupta 1-3/+3
2024-08-13chore: Release notion version 0.6.0v0.6.0Gravatar Jake Swenson 1-1/+1
2024-08-12add new props (#66)Gravatar Ivy Pierlot 2-23/+115
2023-02-25Add new CreateBlock children to page creation (#49)Gravatar Mark Cola 13-747/+924
2023-01-23move And and Or variants to FilterCondition to support recursive nesting (#52)Gravatar Mark Cola 1-14/+84
2023-01-07chore: Release notion version 0.5.1v0.5.1Gravatar Jake Swenson 1-1/+1
2023-01-07Fixed properties docs and added Status (#46)Gravatar AusCyberman 1-32/+70
2023-01-02chore: Release notion version 0.5.0v0.5.0Gravatar Jake Swenson 1-1/+1
2023-01-02style(clippy+fmt): Format code and fix clippy issuesGravatar Jake Swenson 3-3/+6
2023-01-02Add create page functionality (#44)Gravatar ahmetrehaseker 5-12/+42
2022-11-19style(cargo fmt): Add rustfmt config, and fmt codeGravatar Jake Swenson 8-32/+78
2022-11-19chore(docs+deps): Update dependencies, update docs to discuss contributing an...Gravatar Jake Swenson 2-3/+28
2022-05-17(cargo-release) version 0.4.1v0.4.1Gravatar Jake Swenson 1-1/+1
2022-05-17style(cargo fmt): Format codeGravatar Jake Swenson 5-347/+393
2022-05-17(cargo-release) version 0.4.0v0.4.0Gravatar Jake Swenson 1-1/+1
2022-05-17Upgrade notion version (#39)Gravatar Shashank Pachava 16-44/+1189
2022-03-15(cargo-release) version 0.3.5v0.3.5Gravatar Jake Swenson 1-1/+1
2022-03-12Add support for quote and equation blocks (#38)Gravatar Neil Blakey-Milner 1-1/+18
2022-01-11(cargo-release) version 0.3.4v0.3.4Gravatar Jake Swenson 1-1/+1
2022-01-11fix(cargo-release): Fix deprecated cargo release propertyGravatar Jake Swenson 1-1/+1
2022-01-11Add support for code blocks (#35)Gravatar Neil Blakey-Milner 1-1/+13
2021-12-28(cargo-release) version 0.3.3v0.3.3Gravatar Jake Swenson 1-1/+1
2021-12-28fix(#32): Fix rollup value parsing issues (#33)Gravatar Jake Swenson 3-9/+130
2021-12-18(cargo-release) version 0.3.2v0.3.2Gravatar Jake Swenson 1-1/+1
2021-12-17Url property can be null (#26)Gravatar Dmitry Gavrovsky 1-1/+1