This repository was archived by the owner on Mar 30, 2026. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55
66# sgit imports
77from sgit .core import Sgit , DEFAULT_REPO_CONTENT
8+ from sgit .exceptions import *
89
910# 3rd party imports
1011import pytest
@@ -83,3 +84,35 @@ def test_repo_list(sgit):
8384 ## The default configfile after init_repo is empty and usable here
8485 retcode = sgit .repo_list ()
8586 assert retcode == 1
87+
88+
89+ def test_repo_add (sgit ):
90+ retcode = sgit .init_repo ()
91+ assert retcode == None
92+
93+ ## Test exception failure if we send in the wrong data
94+ with pytest .raises (SgitConfigException ) as pytest_wrapped_e :
95+ sgit .repo_add (None , None , None )
96+
97+ assert pytest_wrapped_e .type == SgitConfigException
98+
99+ ## Do a valid add of a new repo
100+ name = 'foobar'
101+ gitrepo = '[email protected] /sgit' 102+ revision = 'master'
103+
104+ sgit .repo_add (name , gitrepo , revision )
105+
106+ saved_data = sgit ._get_config_file ()
107+ assert saved_data == {
108+ 'repos' : {
109+ name : {
110+ 'clone-url' : gitrepo ,
111+ 'revision' : revision
112+ }
113+ }
114+ }
115+
116+ ## If rerunning the same config then it should cause an error
117+ retcode = sgit .repo_add (name , gitrepo , revision )
118+ assert retcode == 1
You can’t perform that action at this time.
0 commit comments