Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,19 @@ All module-internal names are prefixed with an underscore. Such names should
not be used from another module. Modules must avoid reaching into each other's
internals.

## Testing

Everything should have a unit test. In this project, we avoid access to the
internet and to the user's cjdk cache directory in all unit tests. Instead,
temporary directories are used to mock the cache, and, where needed, a mock
server is used to test downloads.

Unit test modules should try not to import cjdk modules other than the one
under test, although sometimes this is unavoidable.

Actual use of the internet (including the Coursier index) and the user cache
directory is limited to integration tests, which are kept separate.

(versioning-scheme)=

## Versioning
Expand Down
34 changes: 0 additions & 34 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,37 +154,3 @@ def test_env_var_set():
with f("CJDK_TEST_ENV_VAR", "testvalue"):
assert os.environ["CJDK_TEST_ENV_VAR"] == "testvalue"
assert "CJDK_TEST_ENV_VAR" not in os.environ


def test_list_vendors():
vendors = _api.list_vendors()
assert vendors is not None
assert "adoptium" in vendors
assert "corretto" in vendors
assert "graalvm" in vendors
assert "ibm-semeru-openj9" in vendors
assert "java-oracle" in vendors
assert "liberica" in vendors
assert "temurin" in vendors
assert "zulu" in vendors


def test_list_jdks():
jdks = _api.list_jdks(cached_only=False)
assert jdks is not None
assert "adoptium:1.21.0.4" in jdks
assert "corretto:21.0.4.7.1" in jdks
assert "graalvm-community:21.0.2" in jdks
assert "graalvm-java21:21.0.2" in jdks
assert "liberica:22.0.2" in jdks
assert "temurin:1.21.0.4" in jdks
assert "zulu:8.0.362" in jdks

cached_jdks = _api.list_jdks()
assert cached_jdks is not None
assert len(cached_jdks) < len(jdks)

zulu_jdks = _api.list_jdks(vendor="zulu", cached_only=False)
assert zulu_jdks is not None
assert len(set(zulu_jdks))
assert all(jdk.startswith("zulu:") for jdk in zulu_jdks)
39 changes: 39 additions & 0 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# This file is part of cjdk.
# Copyright 2022-25 Board of Regents of the University of Wisconsin System
# SPDX-License-Identifier: MIT

from cjdk import _api


def test_list_vendors():
vendors = _api.list_vendors()
assert vendors is not None
assert "adoptium" in vendors
assert "corretto" in vendors
assert "graalvm" in vendors
assert "ibm-semeru-openj9" in vendors
assert "java-oracle" in vendors
assert "liberica" in vendors
assert "temurin" in vendors
assert "zulu" in vendors


def test_list_jdks():
jdks = _api.list_jdks(cached_only=False)
assert jdks is not None
assert "adoptium:1.21.0.4" in jdks
assert "corretto:21.0.4.7.1" in jdks
assert "graalvm-community:21.0.2" in jdks
assert "graalvm-java21:21.0.2" in jdks
assert "liberica:22.0.2" in jdks
assert "temurin:1.21.0.4" in jdks
assert "zulu:8.0.362" in jdks

cached_jdks = _api.list_jdks()
assert cached_jdks is not None
assert len(cached_jdks) < len(jdks)

zulu_jdks = _api.list_jdks(vendor="zulu", cached_only=False)
assert zulu_jdks is not None
assert len(set(zulu_jdks))
assert all(jdk.startswith("zulu:") for jdk in zulu_jdks)