testing: migrate store-ping.sh
notably the bad-store test previously tested *bash*, not lix. we also need to extend the list of non-fatal errors, but that's probably fine Change-Id: I983f4adc8047fe800323099de4037711869ee547
This commit is contained in:
@@ -67,7 +67,7 @@ static void connectToFirstAvailableSocket(AutoCloseFD & sockFD, const std::list<
|
||||
return;
|
||||
} catch (SysError & e) {
|
||||
if (e.errNo == EACCES || e.errNo == EPERM || e.errNo == ECONNREFUSED || e.errNo == ENOENT
|
||||
|| e.errNo == ENOTDIR)
|
||||
|| e.errNo == ENOTDIR || e.errNo == ENOTSOCK)
|
||||
{
|
||||
debug("skipping socket %s: %s", socket, strerror(e.errNo));
|
||||
} else {
|
||||
|
||||
@@ -96,7 +96,6 @@ functional_tests_scripts = [
|
||||
'import-derivation.sh',
|
||||
'db-migration.sh',
|
||||
'bash-profile.sh',
|
||||
'store-ping.sh',
|
||||
'flakes/show.sh',
|
||||
'read-only-store.sh',
|
||||
'nested-sandboxing.sh',
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
source common.sh
|
||||
|
||||
STORE_INFO=$(nix store ping 2>&1)
|
||||
STORE_INFO_JSON=$(nix store ping --json)
|
||||
|
||||
echo "$STORE_INFO" | grep "Store URL: ${NIX_REMOTE}"
|
||||
|
||||
if [[ -v NIX_DAEMON_PACKAGE ]] then
|
||||
DAEMON_VERSION=$($NIX_DAEMON_PACKAGE/bin/nix daemon --version | cut -d' ' -f3)
|
||||
echo "$STORE_INFO" | grep "Version: $DAEMON_VERSION"
|
||||
[[ "$(echo "$STORE_INFO_JSON" | jq -r ".version")" == "$DAEMON_VERSION" ]]
|
||||
fi
|
||||
|
||||
expect 127 NIX_REMOTE=unix:$PWD/store nix store ping || \
|
||||
fail "nix store ping on a non-existent store should fail"
|
||||
|
||||
[[ "$(echo "$STORE_INFO_JSON" | jq -r ".url")" == "${NIX_REMOTE:-local}" ]]
|
||||
@@ -0,0 +1,34 @@
|
||||
import pytest
|
||||
from testlib.fixtures.nix import Nix, NixDaemon
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def setup(nix: Nix):
|
||||
nix.settings.add_xp_feature("nix-command")
|
||||
|
||||
|
||||
def test_ping(nix: Nix):
|
||||
info = nix.nix(["store", "ping"]).run().ok().stderr_plain
|
||||
assert "Store URL: local" in info
|
||||
|
||||
|
||||
def test_ping_json(nix: Nix):
|
||||
info = nix.nix(["store", "ping", "--json"]).run().ok().json()
|
||||
assert info["url"] == "local"
|
||||
|
||||
|
||||
def test_ping_daemon(nix: Nix, daemon: NixDaemon):
|
||||
version = nix.nix(["daemon", "--version"]).run().ok().stdout_plain
|
||||
version = version.splitlines()[0].split()[-1]
|
||||
with daemon(nix) as inner:
|
||||
info = nix.nix(["store", "ping"]).run().ok().stderr_plain
|
||||
assert f"Version: {version}" in info
|
||||
info = inner.nix(["store", "ping", "--json"]).run().ok().json()
|
||||
assert info["url"] == inner.settings.store
|
||||
assert info["version"] == version
|
||||
|
||||
|
||||
def test_ping_bad_store(nix: Nix):
|
||||
nix.settings.store = f"unix:{nix.env.dirs.home}"
|
||||
error = nix.nix(["store", "ping"]).run().expect(1).stderr_plain
|
||||
assert "could not connect" in error
|
||||
Reference in New Issue
Block a user