Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
peczenyj committed Oct 4, 2024
1 parent 1aa3ac1 commit 50722e9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 43 deletions.
35 changes: 2 additions & 33 deletions lang/func_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,37 +73,6 @@ func TestFunc_Receiver_receiver(t *testing.T) {
is.Equal(fn.Receiver(), "Receiver")
}

func TestFunc_Doc(t *testing.T) {
is := is.New(t)

fn, err := loadFunc("../testData/lang/function", "Standalone")
is.NoErr(err)

doc := fn.Doc()
blocks := doc.Blocks()
is.Equal(len(blocks), 5)

is.Equal(blocks[0].Kind(), lang.ParagraphBlock)
is.Equal(blocks[0].Level(), 3)
is.Equal(blocks[0].Text(), "Standalone provides a function that is not part of a type.")

is.Equal(blocks[1].Kind(), lang.ParagraphBlock)
is.Equal(blocks[1].Level(), 3)
is.Equal(blocks[1].Text(), "Additional description can be provided in subsequent paragraphs, including code blocks and headers")

is.Equal(blocks[2].Kind(), lang.HeaderBlock)
is.Equal(blocks[2].Level(), 3)
is.Equal(blocks[2].Text(), "Header A")

is.Equal(blocks[3].Kind(), lang.ParagraphBlock)
is.Equal(blocks[3].Level(), 3)
is.Equal(blocks[3].Text(), "This section contains a code block.")

is.Equal(blocks[4].Kind(), lang.CodeBlock)
is.Equal(blocks[4].Level(), 3)
is.Equal(blocks[4].Text(), "Code Block\nMore of Code Block\n")
}

func TestFunc_Location(t *testing.T) {
is := is.New(t)

Expand Down Expand Up @@ -196,7 +165,7 @@ func TestFunc_textScannerInit(t *testing.T) {
is.Equal(fn.Name(), "Init")
is.Equal(fn.Level(), 3)
is.Equal(fn.Title(), "func (*Scanner) Init")
is.Equal(fn.Summary(), "Init initializes a Scanner with a new source and returns s.")
is.Equal(fn.Summary(), "Init initializes a [Scanner] with a new source and returns s.")
is.Equal(sig, "func (s *Scanner) Init(src io.Reader) *Scanner")
is.Equal(len(fn.Examples()), 0)
}
Expand Down Expand Up @@ -227,7 +196,7 @@ func TestFunc_ioIoutilTempFile(t *testing.T) {
is.Equal(fn.Name(), "TempFile")
is.Equal(fn.Level(), 2)
is.Equal(fn.Title(), "func TempFile")
is.Equal(fn.Summary(), "TempFile creates a new temporary file in the directory dir, opens the file for reading and writing, and returns the resulting *os.File.")
is.Equal(fn.Summary(), "TempFile creates a new temporary file in the directory dir, opens the file for reading and writing, and returns the resulting *[os.File].")
is.Equal(sig, "func TempFile(dir, pattern string) (f *os.File, err error)")
is.Equal(len(fn.Examples()), 2)
}
Expand Down
18 changes: 9 additions & 9 deletions lang/type_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ func TestFunc_netHttpResponseWriter(t *testing.T) {
is.Equal(typ.Summary(), "A ResponseWriter interface is used by an HTTP handler to construct an HTTP response.")
is.Equal(decl, `type ResponseWriter interface {
// Header returns the header map that will be sent by
// WriteHeader. The Header map also is the mechanism with which
// Handlers can set HTTP trailers.
// [ResponseWriter.WriteHeader]. The [Header] map also is the mechanism with which
// [Handler] implementations can set HTTP trailers.
//
// Changing the header map after a call to WriteHeader (or
// Write) has no effect unless the HTTP status code was of the
// Changing the header map after a call to [ResponseWriter.WriteHeader] (or
// [ResponseWriter.Write]) has no effect unless the HTTP status code was of the
// 1xx class or the modified headers are trailers.
//
// There are two ways to set Trailers. The preferred way is to
Expand All @@ -64,21 +64,21 @@ func TestFunc_netHttpResponseWriter(t *testing.T) {
// trailer keys which will come later. In this case, those
// keys of the Header map are treated as if they were
// trailers. See the example. The second way, for trailer
// keys not known to the Handler until after the first Write,
// is to prefix the Header map keys with the TrailerPrefix
// constant value. See TrailerPrefix.
// keys not known to the [Handler] until after the first [ResponseWriter.Write],
// is to prefix the [Header] map keys with the [TrailerPrefix]
// constant value.
//
// To suppress automatic response headers (such as "Date"), set
// their value to nil.
Header() Header
// Write writes the data to the connection as part of an HTTP reply.
//
// If WriteHeader has not yet been called, Write calls
// If [ResponseWriter.WriteHeader] has not yet been called, Write calls
// WriteHeader(http.StatusOK) before writing the data. If the Header
// does not contain a Content-Type line, Write adds a Content-Type set
// to the result of passing the initial 512 bytes of written data to
// DetectContentType. Additionally, if the total size of all written
// [DetectContentType]. Additionally, if the total size of all written
// data is under a few KB and there are no Flush calls, the
// Content-Length header is added automatically.
//
Expand Down
2 changes: 1 addition & 1 deletion magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (

var linter = bintool.Must(bintool.New(
"golangci-lint{{.BinExt}}",
"1.45.2",
"1.61.0",
"https://github.com/golangci/golangci-lint/releases/download/v{{.Version}}/golangci-lint-{{.Version}}-{{.GOOS}}-{{.GOARCH}}{{.ArchiveExt}}",
))

Expand Down

0 comments on commit 50722e9

Please sign in to comment.