package com.magistr.app.config.tenant;

import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;

class TenantConfigWatcherTest {

    @Test
    void configHashUsesSha256Hex() {
        String hash = TenantConfigWatcher.configHash("{\"domain\":\"localhost\"}");

        assertThat(hash).hasSize(64);
        assertThat(hash).matches("[0-9a-f]{64}");
        assertThat(hash).isNotEqualTo(Integer.toHexString("{\"domain\":\"localhost\"}".hashCode()));
    }

    @Test
    void configHashChangesWhenContentChanges() {
        assertThat(TenantConfigWatcher.configHash("tenant-a"))
                .isNotEqualTo(TenantConfigWatcher.configHash("tenant-b"));
    }
}
