mirror of
https://github.com/NixOS/nix
synced 2025-06-27 16:51:15 +02:00
Move unit tests to the location Meson expects them to be
Everything that is a separate subproject should live in the subprojects
directory.
Progress on #2503
This reverts commit 451f8a8c19
.
This commit is contained in:
parent
1cd48008f0
commit
e65510da56
270 changed files with 158 additions and 168 deletions
89
src/libstore-tests/nix_api_store.cc
Normal file
89
src/libstore-tests/nix_api_store.cc
Normal file
|
@ -0,0 +1,89 @@
|
|||
#include "nix_api_util.h"
|
||||
#include "nix_api_util_internal.h"
|
||||
#include "nix_api_store.h"
|
||||
#include "nix_api_store_internal.h"
|
||||
|
||||
#include "tests/nix_api_store.hh"
|
||||
#include "tests/string_callback.hh"
|
||||
|
||||
namespace nixC {
|
||||
|
||||
std::string PATH_SUFFIX = "/g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-name";
|
||||
|
||||
TEST_F(nix_api_util_context, nix_libstore_init)
|
||||
{
|
||||
auto ret = nix_libstore_init(ctx);
|
||||
ASSERT_EQ(NIX_OK, ret);
|
||||
}
|
||||
|
||||
TEST_F(nix_api_store_test, nix_store_get_uri)
|
||||
{
|
||||
std::string str;
|
||||
auto ret = nix_store_get_uri(ctx, store, OBSERVE_STRING(str));
|
||||
ASSERT_EQ(NIX_OK, ret);
|
||||
ASSERT_STREQ("local", str.c_str());
|
||||
}
|
||||
|
||||
TEST_F(nix_api_store_test, InvalidPathFails)
|
||||
{
|
||||
nix_store_parse_path(ctx, store, "invalid-path");
|
||||
ASSERT_EQ(ctx->last_err_code, NIX_ERR_NIX_ERROR);
|
||||
}
|
||||
|
||||
TEST_F(nix_api_store_test, ReturnsValidStorePath)
|
||||
{
|
||||
StorePath * result = nix_store_parse_path(ctx, store, (nixStoreDir + PATH_SUFFIX).c_str());
|
||||
ASSERT_NE(result, nullptr);
|
||||
ASSERT_STREQ("name", result->path.name().data());
|
||||
ASSERT_STREQ(PATH_SUFFIX.substr(1).c_str(), result->path.to_string().data());
|
||||
}
|
||||
|
||||
TEST_F(nix_api_store_test, SetsLastErrCodeToNixOk)
|
||||
{
|
||||
nix_store_parse_path(ctx, store, (nixStoreDir + PATH_SUFFIX).c_str());
|
||||
ASSERT_EQ(ctx->last_err_code, NIX_OK);
|
||||
}
|
||||
|
||||
TEST_F(nix_api_store_test, DoesNotCrashWhenContextIsNull)
|
||||
{
|
||||
ASSERT_NO_THROW(nix_store_parse_path(ctx, store, (nixStoreDir + PATH_SUFFIX).c_str()));
|
||||
}
|
||||
|
||||
TEST_F(nix_api_store_test, get_version)
|
||||
{
|
||||
std::string str;
|
||||
auto ret = nix_store_get_version(ctx, store, OBSERVE_STRING(str));
|
||||
ASSERT_EQ(NIX_OK, ret);
|
||||
ASSERT_STREQ(PACKAGE_VERSION, str.c_str());
|
||||
}
|
||||
|
||||
TEST_F(nix_api_util_context, nix_store_open_dummy)
|
||||
{
|
||||
nix_libstore_init(ctx);
|
||||
Store * store = nix_store_open(ctx, "dummy://", nullptr);
|
||||
ASSERT_EQ(NIX_OK, ctx->last_err_code);
|
||||
ASSERT_STREQ("dummy", store->ptr->getUri().c_str());
|
||||
|
||||
std::string str;
|
||||
nix_store_get_version(ctx, store, OBSERVE_STRING(str));
|
||||
ASSERT_STREQ("", str.c_str());
|
||||
|
||||
nix_store_free(store);
|
||||
}
|
||||
|
||||
TEST_F(nix_api_util_context, nix_store_open_invalid)
|
||||
{
|
||||
nix_libstore_init(ctx);
|
||||
Store * store = nix_store_open(ctx, "invalid://", nullptr);
|
||||
ASSERT_EQ(NIX_ERR_NIX_ERROR, ctx->last_err_code);
|
||||
ASSERT_EQ(nullptr, store);
|
||||
nix_store_free(store);
|
||||
}
|
||||
|
||||
TEST_F(nix_api_store_test, nix_store_is_valid_path_not_in_store)
|
||||
{
|
||||
StorePath * path = nix_store_parse_path(ctx, store, (nixStoreDir + PATH_SUFFIX).c_str());
|
||||
ASSERT_EQ(false, nix_store_is_valid_path(ctx, store, path));
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue