11var assert = require ( "assert" ) ;
22var path = require ( "path" ) ;
33
4- describe ( "Repository " , function ( ) {
4+ describe ( "Remote " , function ( ) {
55 var reposPath = path . resolve ( "test/repos/workdir/.git" ) ;
66
77 var Repository = require ( "../../lib/repository" ) ;
@@ -12,13 +12,50 @@ describe("Repository", function() {
1212
1313 return Repository . open ( reposPath ) . then ( function ( repository ) {
1414 test . repository = repository ;
15+
16+ return Remote . load ( repository , "origin" ) . then ( function ( remote ) {
17+ test . remote = remote ;
18+ } ) ;
19+ } ) ;
20+ } ) ;
21+
22+ after ( function ( ) {
23+ return Remote . load ( this . repository , "origin2" ) . then ( function ( remote ) {
24+ remote . delete ( ) ;
1525 } ) ;
1626 } ) ;
1727
18- it ( "can read git remote url" , function ( ) {
19- return Remote . load ( this . repository , "origin" ) . then ( function ( remote ) {
20- assert . ok ( remote instanceof Remote ) ;
21- assert . equal ( remote . url ( ) , "https://github.com/nodegit/nodegit" ) ;
28+ it ( "can load a remote" , function ( ) {
29+ assert . ok ( this . remote instanceof Remote ) ;
30+ } ) ;
31+
32+ it ( "can read the remote url" , function ( ) {
33+ assert . equal ( this . remote . url ( ) , "https://github.com/nodegit/nodegit" ) ;
34+ } ) ;
35+
36+ it ( "can read the remote name" , function ( ) {
37+ assert . equal ( this . remote . name ( ) , "origin" ) ;
38+ } ) ;
39+
40+ it ( "can create a new remote" , function ( ) {
41+ var repository = this . repository ;
42+ var url = "https://github.com/nodegit/nodegit" ;
43+
44+ return Remote . create ( repository , "origin2" , url ) . then ( function ( ) {
45+ return Remote . load ( repository , "origin2" ) . then ( function ( remote ) {
46+ assert ( remote . url ( ) , "https://github.com/nodegit/nodegit" ) ;
47+ } ) ;
48+ } ) ;
49+ } ) ;
50+
51+ it ( "can delete a remote" , function ( ) {
52+ var repository = this . repository ;
53+ var url = "https://github.com/nodegit/nodegit" ;
54+
55+ return Remote . create ( repository , "origin3" , url ) . then ( function ( ) {
56+ return Remote . load ( repository , "origin3" ) . then ( function ( remote ) {
57+ remote . delete ( ) ;
58+ } ) ;
2259 } ) ;
2360 } ) ;
2461} ) ;
0 commit comments