1- import { ImageName } from "testcontainers" ;
1+ import { ImageName , randomUuid } from "testcontainers" ;
22import { getImage } from "../../../testcontainers/src/utils/test-helper" ;
33import { OllamaContainer } from "./ollama-container" ;
44
@@ -16,27 +16,23 @@ describe("OllamaContainer", { timeout: 180_000 }, () => {
1616 } ) ;
1717
1818 it . skip ( "download model and commit to image" , async ( ) => {
19+ // ollamaPullModel {
1920 await using container = await new OllamaContainer ( IMAGE ) . start ( ) ;
20- // pullModel {
21- const execResult = await container . exec ( [ "ollama" , "pull" , "all-minilm" ] ) ;
22- // }
23- console . log ( execResult . output ) ;
21+ await container . exec ( [ "ollama" , "pull" , "all-minilm" ] ) ;
22+
2423 const response = await fetch ( `${ container . getEndpoint ( ) } /api/tags` ) ;
2524 expect ( response . status ) . toEqual ( 200 ) ;
2625 const body = ( await response . json ( ) ) as { models : { name : string } [ ] } ;
2726 expect ( body . models [ 0 ] . name ) . toContain ( "all-minilm" ) ;
2827
29- const newImageName : string = "tc-ollama-allminilm-" + ( Math . random ( ) + 1 ) . toString ( 36 ) . substring ( 4 ) . toLowerCase ( ) ;
30- // commitToImage {
28+ const newImageName = "tc-ollama-allminilm-" + randomUuid ( ) . substring ( 4 ) ;
3129 await container . commitToImage ( newImageName ) ;
32- // }
3330
34- // substitute {
3531 await using newContainer = await new OllamaContainer ( newImageName ) . start ( ) ;
32+ const newResponse = await fetch ( `${ newContainer . getEndpoint ( ) } /api/tags` ) ;
33+ expect ( newResponse . status ) . toEqual ( 200 ) ;
34+ const newBody = ( await newResponse . json ( ) ) as { models : { name : string } [ ] } ;
35+ expect ( newBody . models [ 0 ] . name ) . toContain ( "all-minilm" ) ;
3636 // }
37- const response2 = await fetch ( `${ newContainer . getEndpoint ( ) } /api/tags` ) ;
38- expect ( response2 . status ) . toEqual ( 200 ) ;
39- const body2 = ( await response2 . json ( ) ) as { models : { name : string } [ ] } ;
40- expect ( body2 . models [ 0 ] . name ) . toContain ( "all-minilm" ) ;
4137 } ) ;
4238} ) ;
0 commit comments