@@ -59,3 +59,107 @@ func TestRepoFolderPathDetermination(t *testing.T) {
5959 require .NoError (t , err )
6060 require .Equal (t , "bitbucket.org/bjoern/arduino_osc" , f )
6161}
62+
63+ func TestLoadRepoListFromFile (t * testing.T ) {
64+ _ , err := LoadRepoListFromFile ("./testdata/nonexistent.txt" )
65+ assert .Error (t , err , "Attempt to load non-existent registry data file" )
66+
67+ repos , err := LoadRepoListFromFile ("./testdata/git_test_repos.txt" )
68+ require .NoError (t , err )
69+
70+ reposAssertion := []* Repo {
71+ {
72+ URL : "https://github.com/arduino-libraries" ,
73+ Types : []string {"Arduino" },
74+ LibraryName : "libraries" ,
75+ },
76+ {
77+ URL :
"[email protected] :PaulStoffregen/Audio.git" ,
78+ Types : []string {"Contributed" },
79+ LibraryName : "Audio" ,
80+ },
81+ {
82+ URL : "https://github.com/PaulStoffregen/OctoWS2811.git" ,
83+ Types : []string {"Arduino" , "Contributed" },
84+ LibraryName : "OctoWS2811" ,
85+ },
86+ {
87+ URL : "https://github.com/PaulStoffregen/AltSoftSerial.git" ,
88+ Types : []string {"Contributed" },
89+ LibraryName : "AltSoftSerial" ,
90+ },
91+ {
92+ URL : "https://github.com/Cheong2K/ble-sdk-arduino.git" ,
93+ Types : []string {"Contributed" },
94+ LibraryName : "ble-sdk-arduino" ,
95+ },
96+ {
97+ URL : "https://github.com/arduino-libraries/Bridge.git" ,
98+ Types : []string {"Contributed" },
99+ LibraryName : "Bridge" ,
100+ },
101+ {
102+ URL : "https://github.com/adafruit/Adafruit_ADS1X15.git" ,
103+ Types : []string {"Recommended" },
104+ LibraryName : "Adafruit_ADS1X15" ,
105+ },
106+ {
107+ URL : "https://github.com/adafruit/Adafruit_ADXL345.git" ,
108+ Types : []string {"Recommended" },
109+ LibraryName : "Adafruit_ADXL345" ,
110+ },
111+ {
112+ URL : "https://github.com/adafruit/Adafruit_AHRS.git" ,
113+ Types : []string {"Recommended" },
114+ LibraryName : "Adafruit_AHRS" ,
115+ },
116+ {
117+ URL : "https://github.com/adafruit/Adafruit_AM2315.git" ,
118+ Types : []string {"Recommended" },
119+ LibraryName : "Adafruit_AM2315" ,
120+ },
121+ {
122+ URL : "https://github.com/arduino-libraries/Scheduler.git" ,
123+ Types : []string {"Arduino" },
124+ LibraryName : "Scheduler" ,
125+ },
126+ {
127+ URL : "https://github.com/arduino-libraries/SD.git" ,
128+ Types : []string {"Arduino" },
129+ LibraryName : "SD" ,
130+ },
131+ {
132+ URL : "https://github.com/arduino-libraries/Servo.git" ,
133+ Types : []string {"Arduino" },
134+ LibraryName : "Servo" ,
135+ },
136+ }
137+
138+ assert .Equal (t , reposAssertion , repos )
139+ }
140+
141+ func TestListRepos (t * testing.T ) {
142+ repos , err := ListRepos ("testdata/git_test_repos.txt" )
143+ require .Error (t , err )
144+
145+ require .Equal (t , 11 , len (repos ))
146+
147+ require .Equal (t , "https://github.com/PaulStoffregen/OctoWS2811.git" , repos [0 ].URL )
148+ require .Equal (t , "https://github.com/PaulStoffregen/AltSoftSerial.git" , repos [1 ].URL )
149+
150+ require .Equal (t , "https://github.com/Cheong2K/ble-sdk-arduino.git" , repos [2 ].URL )
151+ require .Equal (t , "https://github.com/arduino-libraries/Bridge.git" , repos [3 ].URL )
152+ require .Equal (t , "https://github.com/adafruit/Adafruit_ADS1X15.git" , repos [4 ].URL )
153+ require .Equal (t , "https://github.com/adafruit/Adafruit_ADXL345.git" , repos [5 ].URL )
154+ require .Equal (t , "https://github.com/adafruit/Adafruit_AHRS.git" , repos [6 ].URL )
155+ require .Equal (t , "https://github.com/adafruit/Adafruit_AM2315.git" , repos [7 ].URL )
156+ require .Equal (t , "https://github.com/arduino-libraries/Scheduler.git" , repos [8 ].URL )
157+ require .Equal (t , "https://github.com/arduino-libraries/SD.git" , repos [9 ].URL )
158+ require .Equal (t , "https://github.com/arduino-libraries/Servo.git" , repos [10 ].URL )
159+ require .Error (t , err )
160+
161+ error , ok := err .(GitURLsError )
162+ require .True (t , ok )
163+ require .Equal (t , "https://github.com/arduino-libraries" , error .Repos [0 ].URL )
164+ require .
Equal (
t ,
"[email protected] :PaulStoffregen/Audio.git" ,
error .
Repos [
1 ].
URL )
165+ }
0 commit comments