-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparser_4_gocrest_test.go
34 lines (28 loc) · 1.33 KB
/
parser_4_gocrest_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package parser
import (
"github.com/corbym/gocrest/has"
"github.com/corbym/gocrest/is"
"github.com/corbym/gocrest/then"
"testing"
)
// See https://github.com/corbym/gocrest
// (exactly 11 Stars on Github)
func Test_betaflight_message_can_be_parsed__with_GOCREST(t *testing.T) {
info := ParseFirmwareInformation("# Betaflight / SPRACINGF3EVO (SPEV) 3.4.0 Apr 17 2018 / 14:00:13 (b2c247d34) MSP API: 1.39")
then.AssertThat(t, info.FirmwareName, is.EqualTo("Betaflight"))
then.AssertThat(t, info.TargetName, has.Prefix("SPRACING"))
then.AssertThat(t, info.TargetDetail, is.EqualTo("SPEV"))
then.AssertThat(t, info.Version, is.GreaterThanOrEqualTo(int64(3)))
then.AssertThat(t, info.ReleaseDateStr, is.EqualToIgnoringWhitespace("Apr172018"))
then.AssertThat(t, info.ReleaseTime, is.AllOf(has.Prefix("14"), has.Suffix("13")))
then.AssertThat(t, info.GitHash, has.Length(9))
}
func Test_parsing_multiple_lines_returns_first_hit__with_GOCREST(t *testing.T) {
info := ParseFirmwareInformation(
"# bla blubber\n" +
"# Betaflight1 / SPRACINGF3EVO1 (SPEV) 3.4.0 Apr 17 2018 / 14:00:13 (b2c247d34) MSP API: 1.39\n" +
"# Betaflight2 / SPRACINGF3EVO2 (SPEV) 3.4.0 Apr 17 2018 / 14:00:13 (b2c247d34) MSP API: 1.39",
)
then.AssertThat(t, info.FirmwareName, is.EqualTo("Betaflight1"))
then.AssertThat(t, info.TargetName, is.EqualTo("SPRACINGF3EVO1"))
}