1
1
mirror of https://github.com/mcuadros/ascode synced 2024-11-22 17:02:03 +01:00

*: fix test on Windows

This commit is contained in:
Máximo Cuadros 2020-03-27 21:50:48 +01:00
parent 452e5032c7
commit e66c4b456b
No known key found for this signature in database
GPG Key ID: 17A5DFEDC735AE4B
7 changed files with 779 additions and 5 deletions

@ -5,7 +5,7 @@ jobs:
strategy:
fail-fast: false
matrix:
go-version: [1.12.x, 1.13.x, 1.14.x]
go-version: [1.13.x, 1.14.x]
platform: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.platform }}
steps:

@ -1,6 +1,7 @@
package filepath
import (
"path/filepath"
"testing"
"github.com/qri-io/starlib/testdata"
@ -10,6 +11,11 @@ import (
)
func TestFile(t *testing.T) {
if filepath.Separator != '/' {
// TODO(mcuadros): do proper testing on windows.
t.Skip("skiping filepath test for Windows")
}
resolve.AllowFloat = true
thread := &starlark.Thread{Load: testdata.NewLoader(LoadModule, ModuleName)}
starlarktest.SetReporter(thread, t)

@ -1,6 +1,7 @@
package os
import (
"path/filepath"
"testing"
"github.com/qri-io/starlib/testdata"
@ -10,6 +11,11 @@ import (
)
func TestFile(t *testing.T) {
if filepath.Separator != '/' {
// TODO(mcuadros): do proper testing on windows.
t.Skip("skiping os test for Windows")
}
resolve.AllowFloat = true
thread := &starlark.Thread{Load: testdata.NewLoader(LoadModule, ModuleName)}
starlarktest.SetReporter(thread, t)

@ -11,9 +11,12 @@ assert.eq(os.getenv(key), value)
content = "hello world\n"
home = os.getenv("HOME")
os.chdir(home)
assert.eq(os.getwd(), home)
temp = os.temp_dir()
os.chdir(temp)
assert.eq(os.getwd(), temp)
assert.eq(os.write_file("plain.txt", content), None)
assert.eq(os.read_file("plain.txt"), content)

@ -18,7 +18,8 @@ func TestExamples(t *testing.T) {
stdos.Chdir(pwd)
}()
stdos.Chdir(filepath.Join(pwd, "testdata/examples"))
err := stdos.Chdir(filepath.Join(pwd, "testdata", "examples"))
assert.NoError(t, err)
tests, err := filepath.Glob("*.star")
assert.NoError(t, err)

@ -1 +0,0 @@
../../fixtures/state/terraform.tfstate

@ -0,0 +1,759 @@
{
"version": 4,
"terraform_version": "0.12.23",
"serial": 60,
"lineage": "0fb44ef1-8347-c67b-ba44-af2885b0f3c9",
"outputs": {},
"resources": [
{
"mode": "data",
"type": "google_client_config",
"name": "default",
"provider": "provider.google.default",
"instances": [
{
"schema_version": 0,
"attributes": {
"access_token": "foo",
"id": "2020-03-19 15:06:27.25614138 +0000 UTC",
"project": "project-foo",
"region": "us-central",
"zone": ""
}
}
]
},
{
"mode": "data",
"type": "helm_repository",
"name": "stable",
"provider": "provider.helm.default",
"instances": [
{
"schema_version": 0,
"attributes": {
"ca_file": null,
"cert_file": null,
"id": "stable",
"key_file": null,
"metadata": [
{
"name": "stable",
"url": "https://kubernetes-charts.storage.googleapis.com"
}
],
"name": "stable",
"password": null,
"url": "https://kubernetes-charts.storage.googleapis.com",
"username": null
}
}
]
},
{
"mode": "managed",
"type": "google_container_cluster",
"name": "primary",
"provider": "provider.google.default",
"instances": [
{
"schema_version": 1,
"attributes": {
"additional_zones": [],
"addons_config": [
{
"horizontal_pod_autoscaling": [],
"http_load_balancing": [],
"kubernetes_dashboard": [],
"network_policy_config": [
{
"disabled": true
}
]
}
],
"authenticator_groups_config": [],
"cluster_autoscaling": [
{
"auto_provisioning_defaults": [],
"enabled": false,
"resource_limits": []
}
],
"cluster_ipv4_cidr": "10.40.0.0/14",
"default_max_pods_per_node": 110,
"description": "",
"enable_binary_authorization": false,
"enable_intranode_visibility": null,
"enable_kubernetes_alpha": false,
"enable_legacy_abac": false,
"enable_tpu": null,
"endpoint": "35.225.46.99",
"id": "projects/project-foo/locations/us-central1/clusters/primary",
"initial_node_count": 1,
"instance_group_urls": [
"https://www.googleapis.com/compute/v1/projects/project-foo/zones/us-central1-f/instanceGroups/gke-primary-primary-node-pool-f70c34af-grp",
"https://www.googleapis.com/compute/v1/projects/project-foo/zones/us-central1-a/instanceGroups/gke-primary-primary-node-pool-eaab0ef4-grp",
"https://www.googleapis.com/compute/v1/projects/project-foo/zones/us-central1-b/instanceGroups/gke-primary-primary-node-pool-6920a609-grp"
],
"ip_allocation_policy": [],
"label_fingerprint": "a9dc16a7",
"location": "us-central1",
"logging_service": "logging.googleapis.com/kubernetes",
"maintenance_policy": [],
"master_auth": [
{
"client_certificate": "",
"client_certificate_config": [
{
"issue_client_certificate": false
}
],
"client_key": "",
"cluster_ca_certificate": "PHNlY3JldC12YWx1ZT4=",
"password": "",
"username": ""
}
],
"master_authorized_networks_config": [],
"master_version": "1.14.10-gke.17",
"min_master_version": null,
"monitoring_service": "monitoring.googleapis.com/kubernetes",
"name": "primary",
"network": "projects/project-foo/global/networks/default",
"network_policy": [
{
"enabled": false,
"provider": "PROVIDER_UNSPECIFIED"
}
],
"node_config": [
{
"disk_size_gb": 100,
"disk_type": "pd-standard",
"guest_accelerator": [],
"image_type": "COS",
"labels": {},
"local_ssd_count": 0,
"machine_type": "n1-standard-2",
"metadata": {
"disable-legacy-endpoints": "true"
},
"min_cpu_platform": "",
"oauth_scopes": [
"https://www.googleapis.com/auth/logging.write",
"https://www.googleapis.com/auth/monitoring"
],
"preemptible": true,
"sandbox_config": [],
"service_account": "default",
"shielded_instance_config": [
{
"enable_integrity_monitoring": true,
"enable_secure_boot": false
}
],
"tags": [],
"taint": [],
"workload_metadata_config": []
}
],
"node_locations": [
"us-central1-a",
"us-central1-b",
"us-central1-f"
],
"node_pool": [
{
"autoscaling": [],
"initial_node_count": 1,
"instance_group_urls": [
"https://www.googleapis.com/compute/v1/projects/project-foo/zones/us-central1-f/instanceGroupManagers/gke-primary-primary-node-pool-f70c34af-grp",
"https://www.googleapis.com/compute/v1/projects/project-foo/zones/us-central1-a/instanceGroupManagers/gke-primary-primary-node-pool-eaab0ef4-grp",
"https://www.googleapis.com/compute/v1/projects/project-foo/zones/us-central1-b/instanceGroupManagers/gke-primary-primary-node-pool-6920a609-grp"
],
"management": [
{
"auto_repair": false,
"auto_upgrade": true
}
],
"max_pods_per_node": 0,
"name": "primary-node-pool",
"name_prefix": "",
"node_config": [
{
"disk_size_gb": 100,
"disk_type": "pd-standard",
"guest_accelerator": [],
"image_type": "COS",
"labels": {},
"local_ssd_count": 0,
"machine_type": "n1-standard-2",
"metadata": {
"disable-legacy-endpoints": "true"
},
"min_cpu_platform": "",
"oauth_scopes": [
"https://www.googleapis.com/auth/logging.write",
"https://www.googleapis.com/auth/monitoring"
],
"preemptible": true,
"sandbox_config": [],
"service_account": "default",
"shielded_instance_config": [
{
"enable_integrity_monitoring": true,
"enable_secure_boot": false
}
],
"tags": [],
"taint": [],
"workload_metadata_config": []
}
],
"node_count": 1,
"version": "1.14.10-gke.17"
}
],
"node_version": "1.14.10-gke.17",
"operation": null,
"pod_security_policy_config": [],
"private_cluster_config": [],
"project": "project-foo",
"region": null,
"remove_default_node_pool": true,
"resource_labels": {},
"services_ipv4_cidr": "10.43.240.0/20",
"subnetwork": "projects/project-foo/regions/us-central1/subnetworks/default",
"timeouts": null,
"vertical_pod_autoscaling": [],
"zone": null
},
"private": "PHNlY3JldC12YWx1ZT4="
}
]
},
{
"mode": "managed",
"type": "google_container_node_pool",
"name": "primary-node-pool",
"provider": "provider.google.default",
"instances": [
{
"schema_version": 1,
"attributes": {
"autoscaling": [],
"cluster": "primary",
"id": "projects/project-foo/locations/us-central1/clusters/primary/nodePools/primary-node-pool",
"initial_node_count": 1,
"instance_group_urls": [
"https://www.googleapis.com/compute/v1/projects/project-foo/zones/us-central1-f/instanceGroupManagers/gke-primary-primary-node-pool-f70c34af-grp",
"https://www.googleapis.com/compute/v1/projects/project-foo/zones/us-central1-a/instanceGroupManagers/gke-primary-primary-node-pool-eaab0ef4-grp",
"https://www.googleapis.com/compute/v1/projects/project-foo/zones/us-central1-b/instanceGroupManagers/gke-primary-primary-node-pool-6920a609-grp"
],
"location": "us-central1",
"management": [
{
"auto_repair": false,
"auto_upgrade": true
}
],
"max_pods_per_node": null,
"name": "primary-node-pool",
"name_prefix": "",
"node_config": [
{
"disk_size_gb": 100,
"disk_type": "pd-standard",
"guest_accelerator": [],
"image_type": "COS",
"labels": {},
"local_ssd_count": 0,
"machine_type": "n1-standard-2",
"metadata": {
"disable-legacy-endpoints": "true"
},
"min_cpu_platform": "",
"oauth_scopes": [
"https://www.googleapis.com/auth/logging.write",
"https://www.googleapis.com/auth/monitoring"
],
"preemptible": true,
"sandbox_config": [],
"service_account": "default",
"shielded_instance_config": [
{
"enable_integrity_monitoring": true,
"enable_secure_boot": false
}
],
"tags": [],
"taint": [],
"workload_metadata_config": []
}
],
"node_count": 1,
"project": "project-foo",
"region": null,
"timeouts": null,
"version": "1.14.10-gke.17",
"zone": null
},
"private": "PHNlY3JldC12YWx1ZT4=",
"dependencies": [
"google_container_cluster.primary"
]
}
]
},
{
"mode": "managed",
"type": "helm_release",
"name": "foo",
"provider": "provider.helm.default",
"instances": [
{
"schema_version": 0,
"attributes": {
"atomic": false,
"chart": "foo",
"cleanup_on_fail": false,
"dependency_update": false,
"devel": null,
"disable_crd_hooks": false,
"disable_webhooks": false,
"force_update": false,
"id": "foo",
"keyring": null,
"max_history": 0,
"metadata": [
{
"chart": "foo",
"name": "foo",
"namespace": "default",
"revision": 2,
"values": "{\"env\":{\"NATS_CLUSTER\":\"nats-streaming-cluster\",\"NATS_URL\":\"nats://nats-cluster:4222\"},\"image\":{\"name\":\"docker.pkg.github.com/bar/foo/release\",\"tag\":\"v0.0.1\"},\"imagePullSecrets\":[{\"name\":\"dockercfg\"}]}",
"version": "0.1.0"
}
],
"name": "foo",
"namespace": "default",
"recreate_pods": false,
"render_subchart_notes": true,
"replace": false,
"repository": "https://kubernetes-charts.storage.googleapis.com",
"repository_ca_file": null,
"repository_cert_file": null,
"repository_key_file": null,
"repository_password": null,
"repository_username": null,
"reset_values": false,
"reuse_values": false,
"set": [],
"set_sensitive": [],
"set_string": [],
"skip_crds": false,
"status": "deployed",
"timeout": 300,
"values": [
"env:\n NATS_CLUSTER: nats-streaming-cluster\n NATS_URL: nats://nats-cluster:4222\nimage:\n name: docker.pkg.github.com/bar/foo/release\n tag: v0.0.1\nimagePullSecrets:\n- name: dockercfg\n"
],
"verify": false,
"version": "0.1.0",
"wait": true
},
"private": "bnVsbA==",
"dependencies": [
"google_container_cluster.primary"
]
}
]
},
{
"mode": "managed",
"type": "helm_release",
"name": "nats-operator",
"provider": "provider.helm.default",
"instances": [
{
"schema_version": 0,
"attributes": {
"atomic": false,
"chart": "nats-operator",
"cleanup_on_fail": false,
"dependency_update": false,
"devel": null,
"disable_crd_hooks": false,
"disable_webhooks": false,
"force_update": false,
"id": "nats-operator",
"keyring": null,
"max_history": 0,
"metadata": [
{
"chart": "nats-operator",
"name": "nats-operator",
"namespace": "default",
"revision": 1,
"values": "{\"cluster\":{\"auth\":{\"enabled\":false}},\"image\":{\"tag\":\"0.6.2\"}}",
"version": "0.1.2"
}
],
"name": "nats-operator",
"namespace": "default",
"recreate_pods": false,
"render_subchart_notes": true,
"replace": false,
"repository": "https://kubernetes-charts.storage.googleapis.com",
"repository_ca_file": null,
"repository_cert_file": null,
"repository_key_file": null,
"repository_password": null,
"repository_username": null,
"reset_values": false,
"reuse_values": false,
"set": [
{
"name": "cluster.auth.enabled",
"value": "false"
},
{
"name": "image.tag",
"value": "0.6.2"
}
],
"set_sensitive": [],
"set_string": [],
"skip_crds": false,
"status": "deployed",
"timeout": 300,
"values": null,
"verify": false,
"version": "0.1.2",
"wait": true
},
"private": "bnVsbA==",
"dependencies": [
"google_container_cluster.primary"
]
}
]
},
{
"mode": "managed",
"type": "helm_release",
"name": "nats-streaming-operator",
"provider": "provider.helm.default",
"instances": [
{
"schema_version": 0,
"attributes": {
"atomic": false,
"chart": "nats-streaming-operator",
"cleanup_on_fail": false,
"dependency_update": false,
"devel": null,
"disable_crd_hooks": false,
"disable_webhooks": false,
"force_update": false,
"id": "nats-streaming-operator",
"keyring": null,
"max_history": 0,
"metadata": [
{
"chart": "nats-streaming-operator",
"name": "nats-streaming-operator",
"namespace": "default",
"revision": 1,
"values": "{\"cluster\":{\"size\":1},\"livenessProbe\":{\"enabled\":false},\"readinessProbe\":{\"enabled\":false}}",
"version": "1.0.0"
}
],
"name": "nats-streaming-operator",
"namespace": "default",
"recreate_pods": false,
"render_subchart_notes": true,
"replace": false,
"repository": "https://kubernetes-charts.storage.googleapis.com",
"repository_ca_file": null,
"repository_cert_file": null,
"repository_key_file": null,
"repository_password": null,
"repository_username": null,
"reset_values": false,
"reuse_values": false,
"set": [
{
"name": "cluster.size",
"value": "1"
},
{
"name": "livenessProbe.enabled",
"value": "false"
},
{
"name": "readinessProbe.enabled",
"value": "false"
}
],
"set_sensitive": [],
"set_string": [],
"skip_crds": false,
"status": "deployed",
"timeout": 300,
"values": null,
"verify": false,
"version": "1.0.0",
"wait": true
},
"private": "bnVsbA==",
"dependencies": [
"google_container_cluster.primary",
"helm_release.nats-operator"
]
}
]
},
{
"mode": "managed",
"type": "helm_release",
"name": "podinfo",
"provider": "provider.helm.default",
"instances": [
{
"schema_version": 0,
"attributes": {
"atomic": false,
"chart": "podinfo",
"cleanup_on_fail": false,
"dependency_update": false,
"devel": null,
"disable_crd_hooks": false,
"disable_webhooks": false,
"force_update": false,
"id": "podinfo",
"keyring": null,
"max_history": 0,
"metadata": [
{
"chart": "podinfo",
"name": "podinfo",
"namespace": "default",
"revision": 3,
"values": "{\"image\":{\"tag\":\"3.2.0\"}}",
"version": "3.1.8"
}
],
"name": "podinfo",
"namespace": "default",
"recreate_pods": false,
"render_subchart_notes": true,
"replace": false,
"repository": "https://kubernetes-charts.storage.googleapis.com",
"repository_ca_file": null,
"repository_cert_file": null,
"repository_key_file": null,
"repository_password": null,
"repository_username": null,
"reset_values": false,
"reuse_values": false,
"set": [
{
"name": "image.tag",
"value": "3.2.0"
}
],
"set_sensitive": [],
"set_string": [],
"skip_crds": false,
"status": "deployed",
"timeout": 300,
"values": null,
"verify": false,
"version": "3.1.8",
"wait": true
},
"private": "PHNlY3JldC12YWx1ZT4=",
"dependencies": [
"google_container_cluster.primary"
]
}
]
},
{
"mode": "managed",
"type": "helm_release",
"name": "prometheus-operator",
"provider": "provider.helm.default",
"instances": [
{
"schema_version": 0,
"attributes": {
"atomic": false,
"chart": "prometheus-operator",
"cleanup_on_fail": false,
"dependency_update": false,
"devel": null,
"disable_crd_hooks": false,
"disable_webhooks": false,
"force_update": false,
"id": "prometheus-operator",
"keyring": null,
"max_history": 0,
"metadata": [
{
"chart": "prometheus-operator",
"name": "prometheus-operator",
"namespace": "monitoring",
"revision": 1,
"values": "{\"prometheus\":{\"additionalServiceMonitors\":[{\"endpoints\":[{\"interval\":\"5s\",\"port\":\"http\"},{\"interval\":\"5s\",\"port\":\"http-metrics\"}],\"name\":\"default\",\"namespaceSelector\":{\"matchNames\":[\"default\"]},\"selector\":{\"matchExpressions\":[{\"key\":\"app\",\"operator\":\"Exists\"}]}}]}}",
"version": "8.12.2"
}
],
"name": "prometheus-operator",
"namespace": "monitoring",
"recreate_pods": false,
"render_subchart_notes": true,
"replace": false,
"repository": "stable",
"repository_ca_file": null,
"repository_cert_file": null,
"repository_key_file": null,
"repository_password": null,
"repository_username": null,
"reset_values": false,
"reuse_values": false,
"set": [],
"set_sensitive": [],
"set_string": [],
"skip_crds": false,
"status": "deployed",
"timeout": 300,
"values": [
"prometheus:\n additionalServiceMonitors:\n - name: default\n selector: \n matchExpressions:\n - {key: app, operator: Exists}\n namespaceSelector:\n matchNames:\n - default\n endpoints:\n - port: http\n interval: 5s\n - port: http-metrics\n interval: 5s"
],
"verify": false,
"version": "8.12.2",
"wait": true
},
"private": "bnVsbA==",
"dependencies": [
"google_container_cluster.primary",
"kubernetes_namespace.monitoring"
]
}
]
},
{
"mode": "managed",
"type": "kubernetes_cluster_role_binding",
"name": "terraform",
"provider": "provider.kubernetes.default",
"instances": [
{
"schema_version": 0,
"attributes": {
"id": "terraform-cluster-admin-binding",
"metadata": [
{
"annotations": {},
"generation": 0,
"labels": {},
"name": "terraform-cluster-admin-binding",
"resource_version": "2206",
"self_link": "/apis/rbac.authorization.k8s.io/v1/clusterrolebindings/terraform-cluster-admin-binding",
"uid": "fba261de-686f-11ea-b1f8-42010a800036"
}
],
"role_ref": [
{
"api_group": "rbac.authorization.k8s.io",
"kind": "ClusterRole",
"name": "cluster-admin"
}
],
"subject": [
{
"api_group": "rbac.authorization.k8s.io",
"kind": "User",
"name": "terraform@project-foo-terraform.iam.gserviceaccount.com",
"namespace": "default"
}
]
},
"private": "bnVsbA==",
"dependencies": [
"google_container_cluster.primary"
]
}
]
},
{
"mode": "managed",
"type": "kubernetes_namespace",
"name": "monitoring",
"provider": "provider.kubernetes.default",
"instances": [
{
"schema_version": 0,
"attributes": {
"id": "monitoring",
"metadata": [
{
"annotations": {},
"generate_name": "",
"generation": 0,
"labels": {},
"name": "monitoring",
"resource_version": "2198",
"self_link": "/api/v1/namespaces/monitoring",
"uid": "fb98191c-686f-11ea-b1f8-42010a800036"
}
],
"timeouts": null
},
"private": "PHNlY3JldC12YWx1ZT4=",
"dependencies": [
"google_container_cluster.primary"
]
}
]
},
{
"mode": "managed",
"type": "kubernetes_secret",
"name": "dockercfg",
"provider": "provider.kubernetes.default",
"instances": [
{
"schema_version": 0,
"attributes": {
"data": {
".dockerconfigjson": "<secret-dockerconfigjson>"
},
"id": "default/dockercfg",
"metadata": [
{
"annotations": {},
"generate_name": "",
"generation": 0,
"labels": {},
"name": "dockercfg",
"namespace": "default",
"resource_version": "405597",
"self_link": "/api/v1/namespaces/default/secrets/dockercfg",
"uid": "22163d01-6947-11ea-a5ba-42010a80002b"
}
],
"type": "kubernetes.io/dockerconfigjson"
},
"private": "PHNlY3JldC12YWx1ZT4=",
"dependencies": [
"google_container_cluster.primary"
]
}
]
}
]
}

@ -71,4 +71,4 @@ example.ami = "ami-2757f631"
example.instance_type = "t2.micro"
example.depends_on(bucket)
assert.eq(hcl(tf), os.read_file("fixtures/aws.tf"))
assert.eq(hcl(tf).replace("\r", ""), os.read_file("fixtures/aws.tf").replace("\r", ""))