Fix unsafeGetAttrPos test

This commit is contained in:
Eelco Dolstra 2022-07-14 16:15:35 +02:00
parent 7d5e209f23
commit b4c354b013

View file

@ -148,15 +148,15 @@ namespace nix {
} }
TEST_F(PrimOpTest, unsafeGetAttrPos) { TEST_F(PrimOpTest, unsafeGetAttrPos) {
// The `y` attribute is at position state.corepkgsFS->addFile(CanonPath("foo.nix"), "{ y = \"x\"; }");
const char* expr = "builtins.unsafeGetAttrPos \"y\" { y = \"x\"; }";
auto expr = "builtins.unsafeGetAttrPos \"y\" (import <nix/foo.nix>)";
auto v = eval(expr); auto v = eval(expr);
ASSERT_THAT(v, IsAttrsOfSize(3)); ASSERT_THAT(v, IsAttrsOfSize(3));
auto file = v.attrs->find(createSymbol("file")); auto file = v.attrs->find(createSymbol("file"));
ASSERT_NE(file, nullptr); ASSERT_NE(file, nullptr);
// FIXME: The file when running these tests is the input string?!? ASSERT_THAT(*file->value, IsStringEq("/foo.nix"));
ASSERT_THAT(*file->value, IsStringEq(expr));
auto line = v.attrs->find(createSymbol("line")); auto line = v.attrs->find(createSymbol("line"));
ASSERT_NE(line, nullptr); ASSERT_NE(line, nullptr);
@ -164,7 +164,7 @@ namespace nix {
auto column = v.attrs->find(createSymbol("column")); auto column = v.attrs->find(createSymbol("column"));
ASSERT_NE(column, nullptr); ASSERT_NE(column, nullptr);
ASSERT_THAT(*column->value, IsIntEq(33)); ASSERT_THAT(*column->value, IsIntEq(3));
} }
TEST_F(PrimOpTest, hasAttr) { TEST_F(PrimOpTest, hasAttr) {