Skip to content

Commit abc7cd5

Browse files
committed
fix: test-unit in make file fixed.
- README updated; How to run integration and unit tests content changed.
1 parent 267a7ba commit abc7cd5

File tree

2 files changed

+13
-38
lines changed

2 files changed

+13
-38
lines changed

.github/scripts/gcs/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ clean-gcs:
8080

8181
# Perform only unit tests
8282
test-unit:
83-
cd ../../.. && go run github.com/onsi/ginkgo/v2/ginkgo -r --skip-package integration
83+
cd ../../.. && go run github.com/onsi/ginkgo/v2/ginkgo --skip-package=integration ./gcs/...
8484

8585
# Perform all tests, including integration tests.
8686
test-int:
@@ -102,6 +102,7 @@ help:
102102
@echo " clean-gcs: remove external GCS buckets"
103103
@echo " test-fast-int: run an reduced integration test suite (presubmit)"
104104
@echo " test-int: run the full integration test (CI only)"
105+
@echo " test-unit: run unit tests"
105106
@echo ""
106107
@echo "expected environment variables:"
107108
@echo " GOOGLE_SERVICE_ACCOUNT=contents of a JSON service account key"

gcs/README.md

Lines changed: 11 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -48,41 +48,15 @@ The command line tool expects a JSON configuration file. Run `storage-cli-gcs --
4848
will be used if they exist (either through `gcloud auth application-default login` or a [service account](https://cloud.google.com/iam/docs/understanding-service-accounts)).
4949
If they don't exist the client will fall back to `none` behavior.
5050

51-
## Running Integration Tests
52-
53-
1. Ensure [gcloud](https://cloud.google.com/sdk/downloads) is installed and you have authenticated (`gcloud auth login`).
54-
These credentials will be used by the Makefile to create/destroy Google Cloud Storage buckets for testing.
55-
1. Set the Google Cloud project: `gcloud config set project <your project>`
56-
1. Generate a service account with the `Storage Admin` role for your project and set the contents as
57-
the environment variable `GOOGLE_APPLICATION_CREDENTIALS`, for example:
58-
```bash
59-
export project_id=$(gcloud config get-value project)
60-
61-
export service_account_name=storage-cli-gcs-integration-tests
62-
export service_account_email=${service_account_name}@${project_id}.iam.gserviceaccount.com
63-
credentials_file=$(mktemp)
64-
65-
gcloud config set project ${project_id}
66-
gcloud iam service-accounts create ${service_account_name} --display-name "Integration Test Access for storage-cli-gcs "
67-
gcloud iam service-accounts keys create ${credentials_file} --iam-account ${service_account_email}
68-
gcloud project add-iam-policy-binding ${project_id} --member serviceAccount:${service_account_email} --role roles/storage.admin
69-
70-
export GOOGLE_SERVICE_ACCOUNT="$(cat ${credentials_file})"
71-
export GOOGLE_APPLICATION_CREDENTIALS="$(cat ${credentials_file})"
72-
export LC_ALL=C # fix `tr` complaining about "illegal byte sequence" on OSX
73-
```
74-
1. Run the unit and fast integration tests: `make test-fast-int`
75-
1. Clean up buckets: `make clean-gcs`
76-
77-
## Development
51+
## Running Unit Tests
52+
1. Use the command `make -C .github/scripts/gcs test-unit`
7853

79-
* A Makefile is provided that automates integration testing. Try `make help` to get started.
80-
* [gvt](https://godoc.org/github.com/FiloSottile/gvt) is used for vendoring.
81-
82-
## Contributing
83-
84-
For details on how to contribute to this project - including filing bug reports and contributing code changes - please see [CONTRIBUTING.md](./CONTRIBUTING.md).
85-
86-
## License
87-
88-
This tool is licensed under Apache 2.0. Full license text is available in [LICENSE](LICENSE).
54+
## Running Integration Tests
55+
1. Create a service account with the `Storage Admin` role.
56+
1. Create a new key for your service account and download credential as JSON file.
57+
1. Export json content with `export google_json_key_data="$(cat <path-to-json-file.json>)"`.
58+
1. Export `export SKIP_LONG_TESTS=yes` if you want to run only the fast running tests.
59+
1. Navigate to project's root folder.
60+
1. Run environment setup script to create buckets `/.github/scripts/gcs/setup.sh`.
61+
1. Run tests `/.github/scripts/gcs/run-int.sh`.
62+
1. Run environment teardown script to delete resources `/.github/scripts/gcs/teardown.sh`.

0 commit comments

Comments
 (0)