/**
 * Resource validator usage examples
 * Tests moved to server/environment to match new location
 */

import { describe, it, expect } from 'vitest'
import { canExecuteResource, detectEnvironment } from './server/environment'

// Example usage with AIResource
const devResource = {
  resourceId: 'basic-agent',
  name: 'Basic Agent',
  description: 'A basic agent',
  version: '1.0.0',
  type: 'agent' as const,
  status: 'dev' as const
}

const prodResource = {
  resourceId: 'prod-agent',
  name: 'Production Agent',
  description: 'A production agent',
  version: '1.0.0',
  type: 'agent' as const,
  status: 'prod' as const
}

describe('resource-validator', () => {
  describe('canExecuteResource', () => {
    it('should block dev resources in production', () => {
      expect(canExecuteResource(devResource, 'production')).toBe(false)
    })

    it('should allow prod resources in production', () => {
      expect(canExecuteResource(prodResource, 'production')).toBe(true)
    })

    it('should allow dev resources in development', () => {
      expect(canExecuteResource(devResource, 'development')).toBe(true)
    })

    it('should allow dev resources in staging', () => {
      expect(canExecuteResource(devResource, 'staging')).toBe(true)
    })

    it('should allow prod resources in all environments', () => {
      expect(canExecuteResource(prodResource, 'production')).toBe(true)
      expect(canExecuteResource(prodResource, 'development')).toBe(true)
      expect(canExecuteResource(prodResource, 'staging')).toBe(true)
    })
  })

  describe('detectEnvironment', () => {
    it('should detect environment from process.env.NODE_ENV', () => {
      // Note: detectEnvironment now reads directly from process.env.NODE_ENV
      // In test environment, this will be 'test' which defaults to 'development'
      const result = detectEnvironment()
      expect(['development', 'staging', 'production']).toContain(result)
      // Test environment typically returns 'development'
      expect(result).toBe('development')
    })
  })
})
