diff --git a/src/vstore/mount.c b/src/vstore/mount.c index 1afc1acd..baa20aaf 100644 --- a/src/vstore/mount.c +++ b/src/vstore/mount.c @@ -1042,7 +1042,7 @@ int16_t corto_mount_resume( } while (true); } - if (r) { + if (r && !(r->flags & CORTO_RESULT_HIDDEN) && strcmp(r->type, "unknown")) { corto_object out = o; int16_t resume_failed = corto_mount_resumeResult( this, parent, id, r, &out); diff --git a/test/vstore/model.corto b/test/vstore/model.corto index 4ee91432..b2ee3a90 100644 --- a/test/vstore/model.corto +++ b/test/vstore/model.corto @@ -648,6 +648,8 @@ observer tc_resumeWithAutoFilter() tc_declareAndResume() tc_lookupAndResumeUnknown() + tc_defineUnknown() + tc_defineHidden() method setup() diff --git a/test/vstore/src/HiddenParentMount.c b/test/vstore/src/HiddenParentMount.c index c6653fd2..f71ff05e 100644 --- a/test/vstore/src/HiddenParentMount.c +++ b/test/vstore/src/HiddenParentMount.c @@ -13,7 +13,7 @@ int16_t test_HiddenParentMount_construct( "foo", NULL, ".", - "void", + "int32", 0, CORTO_RESULT_HIDDEN ); @@ -28,6 +28,16 @@ int16_t test_HiddenParentMount_construct( CORTO_RESULT_LEAF ); + corto_record__assign( + corto_recordList__append_alloc(this->items), + "helloworld", + NULL, + ".", + "unknown", + 0, + CORTO_RESULT_LEAF + ); + return corto_super_construct(this); } diff --git a/test/vstore/src/ResumeSink.c b/test/vstore/src/ResumeSink.c index ae5f6e2f..09eb1210 100644 --- a/test/vstore/src/ResumeSink.c +++ b/test/vstore/src/ResumeSink.c @@ -2017,3 +2017,77 @@ void test_ResumeSink_tc_lookupAndResumeUnknown( test_assert(corto_delete(o) == 0); test_assert(corto_delete(m) == 0); } + +void test_ResumeSink_tc_defineHidden( + test_ResumeSink this) +{ + /* Create mount with a hidden object 'foo' */ + corto_mount m = corto_subscribe("//") + .from("/data") + .mount(test_HiddenParentMount_o, "{ownership: LOCAL_SOURCE}"); + test_assert(m != NULL); + + corto_object o = corto(CORTO_DECLARE|CORTO_RECURSIVE_DECLARE|CORTO_RESUME, { + .parent = data_o, .id = "foo", .type = corto_int32_o}); + + test_assert(o != NULL); + test_assertstr(corto_idof(o), "foo"); + test_assertref(corto_typeof(o), corto_int32_o); + + /* Even though mount provides object, object should not be resumed because + * the object is HIDDEN */ + test_assert(!corto_check_state(o, CORTO_VALID)); + test_assert(!corto_isresumed(o)); + + test_assert(corto_delete(o) == 0); + test_assert(corto_delete(m) == 0); +} + +static int defineUnknownCount = 0; + +void defineUnknownCallback(corto_subscriber_event *e) { + if (e->event == CORTO_DEFINE) { + defineUnknownCount ++; + } +} + +void test_ResumeSink_tc_defineUnknown( + test_ResumeSink this) +{ + /* Create mount with a unknown object 'helloworld' */ + corto_mount m = corto_subscribe("//") + .from("/data") + .mount(test_HiddenParentMount_o, "{ownership: LOCAL_SOURCE}"); + test_assert(m != NULL); + + /* Create subscriber that monitors DEFINE events */ + corto_subscriber s = corto_subscribe("helloworld") + .from("data") + .callback(defineUnknownCallback); + + test_assertint(defineUnknownCount, 0); + + corto_object o = corto(CORTO_DECLARE|CORTO_RECURSIVE_DECLARE|CORTO_RESUME, { + .parent = data_o, .id = "helloworld", .type = corto_int32_o}); + + test_assert(o != NULL); + test_assertstr(corto_idof(o), "helloworld"); + test_assertref(corto_typeof(o), corto_int32_o); + + /* Even though mount provides object, object should not be resumed because + * the object is unknown */ + test_assert(!corto_check_state(o, CORTO_VALID)); + test_assert(!corto_isresumed(o)); + test_assertint(defineUnknownCount, 0); + + /* Create object the normal way */ + corto_object p = corto_create(data_o, "helloworld", corto_int32_o); + test_assert(o == p); + test_assert(corto_check_state(p, CORTO_VALID)); + test_assertint(defineUnknownCount, 1); + + test_assert(corto_release(p) == 1); + test_assert(corto_delete(o) == 0); + test_assert(corto_delete(m) == 0); + test_assert(corto_delete(s) == 0); +} diff --git a/test/vstore/src/SelectMount.c b/test/vstore/src/SelectMount.c index a8662cbe..aa2fef1c 100644 --- a/test/vstore/src/SelectMount.c +++ b/test/vstore/src/SelectMount.c @@ -1652,6 +1652,13 @@ void test_SelectMount_tc_selectRecursiveFromMountPointParent( test_assertstr(r->parent, "foo"); test_assertstr(r->type, "void"); + test_assert(corto_iter_hasNext(&it) != 0); + r = corto_iter_next(&it); + test_assert(r != NULL); + test_assertstr(r->id, "helloworld"); + test_assertstr(r->parent, "."); + test_assertstr(r->type, "unknown"); + test_assert(corto_iter_hasNext(&it) == 0); test_assertint(m->on_query_count, 2);