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