Ocpp: reduce timeouts during testing (#7342)

Identifies test using build tags until https://github.com/golang/go/issues/52600 becomes available.
This commit is contained in:
andig 2023-04-10 17:05:20 +02:00 • committed by GitHub
parent 440fdf77a5
commit 7803937a0c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 37 additions and 3 deletions

View file

@ -63,7 +63,7 @@ toml:
test::
@echo "Running testsuite"
CGO_ENABLED=0 go test $(BUILD_TAGS) ./...
CGO_ENABLED=0 go test $(BUILD_TAGS),test ./...
porcelain::
gofmt -w -l $$(find . -name '*.go')

View file

@ -52,8 +52,8 @@ func NewOCPPFromConfig(other map[string]interface{}) (api.Charger, error) {
}{
Connector: 1,
IdTag: defaultIdTag,
ConnectTimeout: 2 * time.Minute,
Timeout: 2 * time.Minute,
ConnectTimeout: ocppConnectTimeout,
Timeout: ocppTimeout,
}
if err := util.DecodeOther(other, &cc); err != nil {

10
charger/ocpp_timeout.go Normal file
View file

@ -0,0 +1,10 @@
//go:build !test
package charger
import "time"
const (
ocppConnectTimeout = 5 * time.Minute
ocppTimeout = 2 * time.Minute
)

View file

@ -0,0 +1,10 @@
//go:build test
package charger
import "time"
const (
ocppConnectTimeout = 1 * time.Second
ocppTimeout = 1 * time.Second
)

10
charger/tags_test.go Normal file
View file

@ -0,0 +1,10 @@
//go:build !test
package charger
import "log"
// TODO remove when https://github.com/golang/go/issues/52600 becomes available
func init() {
log.Fatal("running a test without -tags test")
}

View file

@ -9,6 +9,10 @@ connector: {{ .connector }}
{{- if .idtag }}
idtag: {{ .idtag }}
{{- end }}
{{- if ne .connecttimeout "5m" }}
connecttimeout: {{ .connecttimeout }}
{{- end }}
{{- if ne .timeout "2m" }}
timeout: {{ .timeout }}
{{- end }}
{{- end }}