Skip to content
Snippets Groups Projects
user avatar
Andrew Jenkins authored
The TestTrace/Deployment and TestTrace/HelmRelease test cases fail in
environments where the timezone isn't UTC, because they compare a local time
string to the golden file, which has time in UTC.  Here is an example:

```
--- FAIL: TestTrace (0.12s)
    --- FAIL: TestTrace/Deployment (0.08s)
        main_test.go:337: Mismatch from golden file 'testdata/trace/deployment.golden': Mismatch from expected value (-want +got):
              strings.Join({
                ... // 88 identical bytes
                " Flux\n---\nHelmRelease:    podinfo\nNamespace:      podinfo-8\nRevi",
                "sion:       6.0.0\nStatus:         Last reconciled at 2021-07-16 ",
            -   "15:42:20 +0000 UTC",
            +   "09:42:20 -0600 MDT",
                "\nMessage:        Release reconciliation succeeded\n---\nHelmChart:",
                "      podinfo-podinfo\nNamespace:      flux-system-9\nChart:      ",
                "    podinfo\nVersion:        6.0.0\nRevision:       6.0.0\nStatus: ",
                "        Last reconciled at 2021-07-16 ",
            -   "15:32:09 +0000 UTC",
            +   "09:32:09 -0600 MDT",
                "\nMessage:        Fetched revision: 6.0.0\n---\nHelmRepository: pod",
                "info\nNamespace:      flux-system-9\nURL:            https://stefa",
                "nprodan.github.io/podinfo\nRevision:       8411f23d07d3701f0e96e7",
                "d9e503b7936d7e1d56\nStatus:         Last reconciled at 2021-07-",
            -   "1",
                "1",
            -   " 00:25:46 +0000 UTC",
            +   "0 18:25:46 -0600 MDT",
                "\nMessage:        Fetched revision: 8411f23d07d3701f0e96e7d9e503b",
                "7936d7e1d56\n",
              }, "")
```

This commit fixes the issue by converting the golden test times to local
time before comparing. The utility function toLocalTime() is added to
trace_test.go, and then it is used to provide localized times as
template parameters to the golden files.

Signed-off-by: default avatarAndrew Jenkins <andrew@aspenmesh.io>
437a7a28
History
Name Last commit Last update
..
testdata
alert.go
alert_provider.go
bootstrap.go
bootstrap_bitbucket_server.go
bootstrap_git.go
bootstrap_github.go
bootstrap_gitlab.go
build.go
build_kustomization.go
build_kustomization_test.go
check.go
check_test.go
completion.go
completion_bash.go
completion_fish.go
completion_powershell.go
completion_zsh.go
create.go
create_alert.go
create_alertprovider.go
create_helmrelease.go
create_image.go
create_image_policy.go
create_image_repository.go
create_image_update.go
create_kustomization.go
create_receiver.go
create_secret.go
create_secret_git.go
create_secret_git_test.go
create_secret_helm.go
create_secret_helm_test.go
create_secret_tls.go
create_secret_tls_test.go
create_source.go
create_source_bucket.go
create_source_git.go
create_source_git_test.go
create_source_helm.go
create_tenant.go
create_test.go
delete.go
delete_alert.go
delete_alertprovider.go
delete_helmrelease.go
delete_image.go
delete_image_policy.go
delete_image_repository.go
delete_image_update.go
delete_kustomization.go
delete_receiver.go
delete_source.go
delete_source_bucket.go
delete_source_git.go
delete_source_helm.go
diff.go
diff_kustomization.go
diff_kustomization_test.go
docgen.go
export.go
export_alert.go
export_alertprovider.go
export_helmrelease.go
export_image.go
export_image_policy.go
export_image_repository.go
export_image_update.go
export_kustomization.go
export_receiver.go
export_secret.go
export_source.go
export_source_bucket.go
export_source_git.go
export_source_helm.go
export_test.go
get.go
get_alert.go
get_alertprovider.go
get_all.go
get_helmrelease.go
get_image.go
get_image_all.go
get_image_policy.go
get_image_repository.go
get_image_update.go
get_kustomization.go
get_receiver.go
get_source.go
get_source_all.go
get_source_bucket.go
get_source_chart.go
get_source_git.go
get_source_helm.go
helmrelease.go
helmrelease_test.go
image.go
image_test.go
install.go
kustomization.go