Skip to content

Commit

Permalink
Merge pull request 6436 from hotfix/v4.3.2 into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Project Collection Build Service (51degrees) authored and Project Collection Build Service (51degrees) committed Jan 8, 2022
2 parents 6ba840f + 0afe494 commit 0e967f1
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 63 deletions.
2 changes: 1 addition & 1 deletion ci/common-ci
22 changes: 12 additions & 10 deletions dd/getting_started_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,21 @@ func match(
log.Fatalln(err)
}

returnStr := ""
if !hasValues {
log.Printf("Property %s does not have a matched value.\n", propertyName)
returnStr = fmt.Sprintf("Property %s does not have a matched value.\n", propertyName)
} else {
// Get the values in string
value, err := results.ValuesString(
propertyName,
",")
if err != nil {
log.Fatalln(err)
}
returnStr = fmt.Sprintf("\tIsMobile: %s\n", value)
}

// Get the values in string
value, err := results.ValuesString(
propertyName,
",")
if err != nil {
log.Fatalln(err)
}

return fmt.Sprintf("\tIsMobile: %s\n", value)
return returnStr
}

func runGettingStarted(perf dd.PerformanceProfile) string {
Expand Down
27 changes: 14 additions & 13 deletions dd/match_device_id_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,25 +65,26 @@ func matchDeviceId(

// If results has values for required property
propertyName := "IsMobile"
// TODO: Uncomment once hasValues is fixed in C.
/*hasValues, err := devIdResults.HasValues(propertyName)
hasValues, err := devIdResults.HasValues(propertyName)
if err != nil {
log.Fatalln(err)
}

returnStr := ""
if !hasValues {
log.Printf("Property %s does not have a matched value.\n", propertyName)
}*/

// Get the values in string
value, err := devIdResults.ValuesString(
propertyName,
",")
if err != nil {
log.Fatalln(err)
returnStr = fmt.Sprintf("Property %s does not have a matched value.\n", propertyName)
} else {
// Get the values in string
value, err := devIdResults.ValuesString(
propertyName,
",")
if err != nil {
log.Fatalln(err)
}

returnStr = fmt.Sprintf("\tIsMobile: %s\n", value)
}

return fmt.Sprintf("\tIsMobile: %s\n", value)
return returnStr
}

func runMatchDeviceId(perf dd.PerformanceProfile) string {
Expand Down
71 changes: 36 additions & 35 deletions dd/match_metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,43 +69,44 @@ func matchMetrics(
log.Fatalln(err)
}

returnStr := ""
if !hasValues {
log.Printf("Property %s does not have a matched value.\n", propertyName)
returnStr = fmt.Sprintf("Property %s does not have a matched value.\n", propertyName)
} else {
deviceId, err := results.DeviceId()
if err != nil {
log.Fatalln(err)
}

drift := results.Drift()
difference := results.Difference()
iterations := results.Iterations()
method := results.Method()
methodStr := "NONE"
switch method {
case dd.Performance:
methodStr = "PERFORMANCE"
case dd.Combined:
methodStr = "COMBINED"
case dd.Predictive:
methodStr = "PREDICTIVE"
default:
methodStr = "NONE"
}
// We only use one User-Agent so there can only be one result
matchedUserAgent, err := results.UserAgent(0)
if err != nil {
log.Fatal(err.Error())
}

returnStr = fmt.Sprintf("\tIsMobile: %s\n", value)
returnStr += fmt.Sprintf("\tId: %s\n", deviceId)
returnStr += fmt.Sprintf("\tDrift: %d\n", drift)
returnStr += fmt.Sprintf("\tDifference: %d\n", difference)
returnStr += fmt.Sprintf("\tIterations: %d\n", iterations)
returnStr += fmt.Sprintf("\tMethod: %s\n", methodStr)
returnStr += fmt.Sprintf("\tSub Strings: %s\n", matchedUserAgent)
}

deviceId, err := results.DeviceId()
if err != nil {
log.Fatalln(err)
}

drift := results.Drift()
difference := results.Difference()
iterations := results.Iterations()
method := results.Method()
methodStr := "NONE"
switch method {
case dd.Performance:
methodStr = "PERFORMANCE"
case dd.Combined:
methodStr = "COMBINED"
case dd.Predictive:
methodStr = "PREDICTIVE"
default:
methodStr = "NONE"
}
// We only use one User-Agent so there can only be one result
matchedUserAgent, err := results.UserAgent(0)
if err != nil {
log.Fatal(err.Error())
}

returnStr := fmt.Sprintf("\tIsMobile: %s\n", value)
returnStr += fmt.Sprintf("\tId: %s\n", deviceId)
returnStr += fmt.Sprintf("\tDrift: %d\n", drift)
returnStr += fmt.Sprintf("\tDifference: %d\n", difference)
returnStr += fmt.Sprintf("\tIterations: %d\n", iterations)
returnStr += fmt.Sprintf("\tMethod: %s\n", methodStr)
returnStr += fmt.Sprintf("\tSub Strings: %s\n", matchedUserAgent)
return returnStr
}

Expand Down
2 changes: 1 addition & 1 deletion device-detection-go
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module github.com/51Degrees/device-detection-go-examples/v4
module github.com/51Degrees/device-detection-examples-go/v4

go 1.17

require github.com/51Degrees/device-detection-go/v4 v4.3.1
require github.com/51Degrees/device-detection-go/v4 v4.3.3

replace github.com/51Degrees/device-detection-go/v4 v4.3.1 => ./device-detection-go
replace github.com/51Degrees/device-detection-go/v4 v4.3.3 => ./device-detection-go

0 comments on commit 0e967f1

Please sign in to comment.