c-ipfs/test/cmd/ipfs/test_init.h

51 lines
1.2 KiB
C
Raw Normal View History

2016-10-27 01:14:07 +00:00
/**
* Testing of cmd/ipfs/init
*/
#ifndef __TEST_INIT_H__
#define __TEST_INIT_H__
#include "../../../cmd/ipfs/init.h"
2016-10-27 02:13:32 +00:00
#include "../../../commands/argument.h"
2016-10-27 01:14:07 +00:00
#include <stdio.h>
#include <string.h>
int test_get_init_command() {
2016-10-27 18:11:34 +00:00
struct Command cmd = { 0 };
2016-10-27 02:13:32 +00:00
int retVal = 1;
2016-10-27 01:14:07 +00:00
// make sure its empty
if (cmd.help_text.tagline != NULL) {
fprintf(stderr, "short description should be null\n");
return 0;
}
// grab the stuff
2016-10-27 02:13:32 +00:00
retVal = get_init_command(&cmd);
2016-10-27 01:14:07 +00:00
2016-10-27 02:13:32 +00:00
if (!retVal) {
fprintf(stderr, "Function call to get_init_command not successful. Return was %d\n", retVal);
return retVal;
}
2016-10-27 01:14:07 +00:00
// make sure its right
if (cmd.help_text.tagline == NULL) {
fprintf(stderr, "short description is null\n");
2016-10-27 02:13:32 +00:00
retVal = 0;
} else if (strcmp(cmd.help_text.tagline, "Initializes IPFS config file.") != 0) {
2016-10-27 01:14:07 +00:00
fprintf(stderr, "short description is not null\n");
2016-10-27 02:13:32 +00:00
retVal = 0;
} else if (cmd.argument_count != 1) {
fprintf(stderr, "argument count should be 1");
retVal = 0;
} else {
2016-10-27 18:11:34 +00:00
struct Argument arg1 = *(cmd.arguments[0]);
2016-10-27 02:13:32 +00:00
if (strncmp(arg1.name, "default-config", 14) != 0) {
fprintf(stderr, "arg1 wrong name. Expected %s but got %s\n", "default_config", arg1.name);
retVal = 0;
}
2016-10-27 01:14:07 +00:00
}
2016-10-27 02:13:32 +00:00
uninit_command(&cmd);
return retVal;
2016-10-27 01:14:07 +00:00
}
#endif