55#include <stdlib.h>
66#include <string.h>
77
8+ #include <curl/curl.h>
9+
810#include "addon.h"
911#include "appstate.h"
12+ #include "command.h"
1013#include "config.h"
1114#include "context.h"
1215#include "list.h"
@@ -56,24 +59,51 @@ static bool is_nothing_installed(void)
5659
5760static void test_install_single (void )
5861{
59- assert (system (WOWPKG_EXEC_PATH " install bigwigs" ) == 0 );
60- assert (!is_addons_dir_empty ());
62+ // assert(system(WOWPKG_EXEC_PATH " install bigwigs") == 0);
63+ // assert(!is_addons_dir_empty());
6164
62- /* Check that installed addons show up in list as expected. */
63- /*
64- FILE *fpout = popen(WOWPKG_EXEC_PATH " list", "r");
65- assert(fpout != NULL);
66- char pout[32] = { '\0' };
67- assert(fscanf(fpout, "BigWigs (%31[^)])\n", pout) == 1);
68- assert(fgetc(fpout) == EOF);
69- assert(pclose(fpout) == 0);
70- */
65+ // /* Check that installed addons show up in list as expected. */
66+ // FILE *fpout = popen(WOWPKG_EXEC_PATH " list", "r");
67+ // assert(fpout != NULL);
68+ // char pout[32] = { '\0' };
69+ // assert(fscanf(fpout, "BigWigs (%31[^)])\n", pout) == 1);
70+ // assert(fgetc(fpout) == EOF);
71+ // assert(pclose(fpout) == 0);
7172
72- /* Cleanup addons directory. */
73- /*
74- assert(system(WOWPKG_EXEC_PATH " remove bigwigs") == 0);
73+ // /* Cleanup addons directory. */
74+ // assert(system(WOWPKG_EXEC_PATH " remove bigwigs") == 0);
75+ // assert(is_addons_dir_empty());
76+
77+ Context ctx = { 0 };
78+
79+ Config * cfg = config_create ();
80+ assert (config_load (cfg , WOWPKG_USER_FILE_DIR "/config.ini" ) == 0 );
81+
82+ curl_global_init (CURL_GLOBAL_DEFAULT );
83+ CURL * curl = curl_easy_init ();
84+ assert (curl != NULL );
85+
86+ AppState * state = appstate_create ();
87+ assert (state != NULL );
88+
89+ ctx .config = cfg ;
90+ ctx .curl = curl ;
91+ ctx .state = state ;
92+
93+ char * install_args [] = { "install" , "bigwigs" };
94+ assert (cmd_install (& ctx , ARRAY_SIZE (install_args ), install_args , stdout ) == 0 );
95+ assert (!is_addons_dir_empty ());
96+ assert (list_len (ctx .state -> installed ) == 1 );
97+
98+ char * remove_args [] = { "remove" , "bigwigs" };
99+ assert (cmd_remove (& ctx , ARRAY_SIZE (remove_args ), remove_args , stdout ) == 0 );
75100 assert (is_addons_dir_empty ());
76- */
101+ assert (list_len (ctx .state -> installed ) == 0 );
102+
103+ appstate_destroy (state );
104+ curl_easy_cleanup (curl );
105+ curl_global_cleanup ();
106+ config_destroy (cfg );
77107}
78108
79109static void test_install_multiple (void )
@@ -589,7 +619,7 @@ int main(void)
589619 exit (EXIT_FAILURE );
590620 }
591621
592- // test_install_single();
622+ test_install_single ();
593623 // test_install_multiple();
594624 // test_upgrade_single();
595625 // test_upgrade_all();
@@ -603,7 +633,7 @@ int main(void)
603633
604634 /* This should probably only be ran with GitHub token set, otherwise the rate
605635 * limit is a real concern. */
606- test_install_all ();
636+ // test_install_all();
607637
608638 return EXIT_SUCCESS ;
609639}
0 commit comments