import { assertEquals, assertExists } from '@std/assert';
import { BaseProvider, GiteaProvider, GitLabProvider } from '../ts/providers/index.ts';
import { ConnectionManager } from '../ts/classes/connectionmanager.ts';
import { GitopsApp } from '../ts/classes/gitopsapp.ts';
import { StorageManager } from '../ts/storage/index.ts';
import * as smartsecret from '@push.rocks/smartsecret';

Deno.test('GiteaProvider instantiates correctly', () => {
  const provider = new GiteaProvider('test-id', 'https://gitea.example.com', 'test-token');
  assertExists(provider);
  assertEquals(provider.connectionId, 'test-id');
  assertEquals(provider.baseUrl, 'https://gitea.example.com');
});

Deno.test('GitLabProvider instantiates correctly', () => {
  const provider = new GitLabProvider('test-id', 'https://gitlab.example.com', 'test-token');
  assertExists(provider);
  assertEquals(provider.connectionId, 'test-id');
  assertEquals(provider.baseUrl, 'https://gitlab.example.com');
});

Deno.test('ConnectionManager instantiates correctly', () => {
  const storage = new StorageManager({ backend: 'memory' });
  const secret = new smartsecret.SmartSecret({ service: 'gitops-test' });
  const manager = new ConnectionManager(storage, secret);
  assertExists(manager);
});

Deno.test('GitopsApp instantiates correctly', () => {
  const app = new GitopsApp();
  assertExists(app);
  assertExists(app.storageManager);
  assertExists(app.smartSecret);
  assertExists(app.connectionManager);
  assertExists(app.opsServer);
});
