This repository was archived by the owner on Jun 3, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed
main/java/fi/helsinki/cs/tmc/cli/updater
test/java/fi/helsinki/cs/tmc/cli/updater Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -78,7 +78,9 @@ public boolean run() {
7878 File destination = new File (currentBinLocation + binName );
7979
8080 io .println ("Downloading..." );
81- fetchTmcCliBinary (dlUrl , destination );
81+ if (!fetchTmcCliBinary (dlUrl , destination )) {
82+ return false ;
83+ }
8284
8385 io .println ("Running " + destination .getAbsolutePath ());
8486 return runNewTmcCliBinary (destination .getAbsolutePath ());
@@ -136,16 +138,18 @@ protected String fetchLatestReleaseJson() {
136138 * Downloads a binary file from downloadUrl and saves it to destination
137139 * file.
138140 */
139- protected void fetchTmcCliBinary (String downloadUrl , File destination ) {
141+ protected boolean fetchTmcCliBinary (String downloadUrl , File destination ) {
140142 byte [] content = fetchHttpEntity (downloadUrl );
141143 if (content == null ) {
142144 io .println ("Failed to download tmc-cli." );
143- return ;
145+ return false ;
144146 }
145147 try {
146148 FileUtils .writeByteArrayToFile (destination , content );
149+ return true ;
147150 } catch (IOException ex ) {
148151 io .println ("Failed to write the new version into \' " + destination + "\' ." );
152+ return false ;
149153 }
150154 }
151155
Original file line number Diff line number Diff line change @@ -107,7 +107,7 @@ public void downloadsAndRunsNewBinaryIfOk() {
107107 TmcCliUpdater updater = spy (new TmcCliUpdater (io , "0.1.0" , false ));
108108 doReturn (latestJson ).when (updater ).fetchLatestReleaseJson ();
109109 //when(updater.fetchLatestReleaseJson()).thenReturn(latestJson);
110- doNothing ( ).when (updater ).fetchTmcCliBinary (any (String .class ), any (File .class ));
110+ doReturn ( true ).when (updater ).fetchTmcCliBinary (any (String .class ), any (File .class ));
111111 when (updater .runNewTmcCliBinary (any (String .class ))).thenReturn (true );
112112 updater .run ();
113113 assertThat (io .out (), containsString ("A new version of tmc-cli is available!" ));
You can’t perform that action at this time.
0 commit comments