11import { beforeEach , describe , expect , it } from "bun:test" ;
2- import {
3- archive ,
4- CASRegistry ,
5- MemoryRXAStore ,
6- MemoryRXMStore ,
7- manifest ,
8- resource ,
9- } from "@resourcexjs/core" ;
10- import { createStoreX , type StoreX } from "../src/index" ;
2+ import { archive , manifest , resource } from "@resourcexjs/core" ;
3+ import { createStoreX , MemoryRXAStore , MemoryRXMStore , type StoreX } from "../src/index" ;
114
125describe ( "StoreX" , ( ) => {
136 let store : StoreX ;
14- let cas : CASRegistry ;
157
168 beforeEach ( ( ) => {
17- cas = new CASRegistry ( new MemoryRXAStore ( ) , new MemoryRXMStore ( ) ) ;
18- store = createStoreX ( { registry : cas } ) ;
9+ store = createStoreX ( {
10+ blobStore : new MemoryRXAStore ( ) ,
11+ manifestStore : new MemoryRXMStore ( ) ,
12+ } ) ;
1913 } ) ;
2014
2115 describe ( "list" , ( ) => {
2216 it ( "lists all resources" , async ( ) => {
23- await cas . put (
17+ await store . put (
2418 resource (
2519 manifest ( { name : "img-pack" , type : "binary" , tag : "latest" } ) ,
2620 await archive ( { "photo.png" : Buffer . from ( "png-data" ) } )
@@ -35,13 +29,13 @@ describe("StoreX", () => {
3529 } ) ;
3630
3731 it ( "filters by query" , async ( ) => {
38- await cas . put (
32+ await store . put (
3933 resource (
4034 manifest ( { name : "issue-5-files" , type : "binary" , tag : "latest" } ) ,
4135 await archive ( { "a.png" : Buffer . from ( "a" ) } )
4236 )
4337 ) ;
44- await cas . put (
38+ await store . put (
4539 resource (
4640 manifest ( { name : "my-skill" , type : "skill" , tag : "latest" } ) ,
4741 await archive ( { "SKILL.md" : Buffer . from ( "# Skill" ) } )
@@ -56,7 +50,7 @@ describe("StoreX", () => {
5650
5751 describe ( "getFile" , ( ) => {
5852 it ( "retrieves a single file by locator and path" , async ( ) => {
59- await cas . put (
53+ await store . put (
6054 resource (
6155 manifest ( { name : "attachments" , type : "binary" , tag : "latest" } ) ,
6256 await archive ( { "screenshot.png" : Buffer . from ( "image-bytes" ) } )
@@ -68,7 +62,7 @@ describe("StoreX", () => {
6862 } ) ;
6963
7064 it ( "returns null for non-existent file" , async ( ) => {
71- await cas . put (
65+ await store . put (
7266 resource (
7367 manifest ( { name : "attachments" , type : "binary" , tag : "latest" } ) ,
7468 await archive ( { "a.txt" : Buffer . from ( "a" ) } )
@@ -82,7 +76,7 @@ describe("StoreX", () => {
8276
8377 describe ( "append" , ( ) => {
8478 it ( "appends files to an existing resource" , async ( ) => {
85- await cas . put (
79+ await store . put (
8680 resource (
8781 manifest ( { name : "issue-3" , type : "binary" , tag : "latest" } ) ,
8882 await archive ( { "img1.png" : Buffer . from ( "first" ) } )
@@ -105,7 +99,7 @@ describe("StoreX", () => {
10599
106100 describe ( "getManifest" , ( ) => {
107101 it ( "returns manifest metadata" , async ( ) => {
108- await cas . put (
102+ await store . put (
109103 resource (
110104 manifest ( { name : "docs" , type : "text" , tag : "1.0.0" , description : "My docs" } ) ,
111105 await archive ( { "readme.md" : Buffer . from ( "Hello" ) } )
@@ -126,7 +120,7 @@ describe("StoreX", () => {
126120
127121 describe ( "has" , ( ) => {
128122 it ( "returns true for existing resource" , async ( ) => {
129- await cas . put (
123+ await store . put (
130124 resource (
131125 manifest ( { name : "exists" , type : "text" , tag : "latest" } ) ,
132126 await archive ( { "a.txt" : Buffer . from ( "a" ) } )
@@ -157,7 +151,7 @@ describe("StoreX", () => {
157151
158152 describe ( "remove" , ( ) => {
159153 it ( "removes a resource" , async ( ) => {
160- await cas . put (
154+ await store . put (
161155 resource (
162156 manifest ( { name : "temp" , type : "text" , tag : "latest" } ) ,
163157 await archive ( { "a.txt" : Buffer . from ( "a" ) } )
0 commit comments