Align documented commands with the CLI, enable optional GUI/test targets, and remove committed API secrets so the project is safer to build and run. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
53 lines
1.4 KiB
C++
53 lines
1.4 KiB
C++
#include "dstalk/dstalk_api.h"
|
|
|
|
#include <cstring>
|
|
#include <filesystem>
|
|
#include <fstream>
|
|
#include <iostream>
|
|
#include <string>
|
|
|
|
int main()
|
|
{
|
|
const auto dir = std::filesystem::temp_directory_path() / "dstalk-smoke-test";
|
|
std::filesystem::create_directories(dir);
|
|
|
|
const auto config_path = dir / "config.toml";
|
|
{
|
|
std::ofstream config(config_path);
|
|
config << "[api]\n"
|
|
<< "provider = \"deepseek\"\n"
|
|
<< "base_url = \"https://api.deepseek.com/v1\"\n"
|
|
<< "api_key = \"test-key\"\n"
|
|
<< "model = \"deepseek-chat\"\n";
|
|
}
|
|
|
|
if (dstalk_init(config_path.string().c_str()) != 0) {
|
|
std::cerr << "dstalk_init failed\n";
|
|
return 1;
|
|
}
|
|
|
|
const auto file_path = dir / "sample.txt";
|
|
if (dstalk_file_write(file_path.string().c_str(), "hello dstalk") != 0) {
|
|
std::cerr << "dstalk_file_write failed\n";
|
|
dstalk_destroy();
|
|
return 1;
|
|
}
|
|
|
|
char* content = nullptr;
|
|
if (dstalk_file_read(file_path.string().c_str(), &content) != 0 || !content) {
|
|
std::cerr << "dstalk_file_read failed\n";
|
|
dstalk_destroy();
|
|
return 1;
|
|
}
|
|
|
|
const bool ok = std::strcmp(content, "hello dstalk") == 0;
|
|
dstalk_free_string(content);
|
|
dstalk_destroy();
|
|
|
|
if (!ok) {
|
|
std::cerr << "unexpected file content\n";
|
|
return 1;
|
|
}
|
|
return 0;
|
|
}
|