I am not able to set it up. #121
Replies: 4 comments 10 replies
-
Can you provide some more information about what you are experiencing? Can you open up the Neotest summary window? Do you see anything suspicious in the Neotest log file? |
Beta Was this translation helpful? Give feedback.
-
package main
import (
"fmt"
"testing"
"time"
)
func Test(t *testing.T) {
type testCase struct {
msg message
expectedText string
expectedCost int
}
tests := []testCase{
{birthdayMessage{time.Date(1994, 03, 21, 0, 0, 0, 0, time.UTC), "John Doe"},
"Hi John Doe, it is your birthday on 1994-03-21T00:00:00Z",
168,
},
{sendingReport{"First Report", 10},
`Your "First Report" report is ready. You've sent 10 messages.`,
183,
},
}
if withSubmit {
tests = append(tests, []testCase{
{birthdayMessage{time.Date(1934, 05, 01, 0, 0, 0, 0, time.UTC), "Bill Deer"},
"Hi Bill Deer, it is your birthday on 1934-05-01T00:00:00Z",
171,
},
{sendingReport{"Second Report", 20},
`Your "Second Report" report is ready. You've sent 20 messages.`,
186,
},
}...)
}
for _, test := range tests {
text, cost := sendMessage(test.msg)
if text != test.expectedText || cost != test.expectedCost {
t.Errorf(
`Test Failed: %+v ->
expected: (%v, %v)
actual: (%v, %v)
`,
test.msg,
test.expectedText,
test.expectedCost,
text,
cost,
)
} else {
fmt.Printf(
`Test Passed: %+v ->
expected: (%v, %v)
actual: (%v, %v)
`,
test.msg,
test.expectedText,
test.expectedCost,
text,
cost,
)
}
}
}
// withSubmit is set at compile time depending
// on which button is used to run the tests
var withSubmit = true |
Beta Was this translation helpful? Give feedback.
-
package main
import (
"fmt"
"time"
)
func sendMessage(msg message) (string, int) {
return msg.getMessage(), len(msg.getMessage()) * 3
}
type message interface {
getMessage() string
}
// don't edit below this line
type birthdayMessage struct {
birthdayTime time.Time
recipientName string
}
func (bm birthdayMessage) getMessage() string {
return fmt.Sprintf("Hi %s, it is your birthday on %s", bm.recipientName, bm.birthdayTime.Format(time.RFC3339))
}
type sendingReport struct {
reportName string
numberOfSends int
}
func (sr sendingReport) getMessage() string {
return fmt.Sprintf(`Your "%s" report is ready. You've sent %v messages.`, sr.reportName, sr.numberOfSends)
}``` |
Beta Was this translation helpful? Give feedback.
-
@fredrikaverpil I figured it out! Once again..Thank you for your time. |
Beta Was this translation helpful? Give feedback.
-
My config --
Beta Was this translation helpful? Give feedback.
All reactions