|
| 1 | +/* |
| 2 | + * Copyright 2024 Salesforce, Inc. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License") |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +package com.netflix.spinnaker.halyard.config.config.v1; |
| 18 | + |
| 19 | +import static org.assertj.core.api.Assertions.assertThat; |
| 20 | + |
| 21 | +import org.junit.jupiter.api.BeforeEach; |
| 22 | +import org.junit.jupiter.api.Test; |
| 23 | +import org.junit.jupiter.api.TestInfo; |
| 24 | +import org.springframework.boot.context.annotation.UserConfigurations; |
| 25 | +import org.springframework.boot.test.context.runner.ApplicationContextRunner; |
| 26 | + |
| 27 | +class HalconfigConfigurationTest { |
| 28 | + |
| 29 | + private final ApplicationContextRunner runner = |
| 30 | + new ApplicationContextRunner() |
| 31 | + .withConfiguration( |
| 32 | + UserConfigurations.of(ResourceConfig.class, HalconfigDirectoryStructure.class)); |
| 33 | + |
| 34 | + @BeforeEach |
| 35 | + void init(TestInfo testInfo) { |
| 36 | + System.out.println("--------------- Test " + testInfo.getDisplayName()); |
| 37 | + } |
| 38 | + |
| 39 | + @Test |
| 40 | + void testHalconfigDirectory() { |
| 41 | + runner.run( |
| 42 | + ctx -> { |
| 43 | + String homeDir = System.getProperty("user.home"); |
| 44 | + assertThat(homeDir).isNotNull(); |
| 45 | + |
| 46 | + assertThat(ctx).hasSingleBean(HalconfigDirectoryStructure.class); |
| 47 | + String halconfigDirectory = ctx.getBean("halconfigDirectory", String.class); |
| 48 | + assertThat(halconfigDirectory).isNotNull(); |
| 49 | + assertThat(halconfigDirectory).isEqualTo(homeDir + "/.hal"); |
| 50 | + HalconfigDirectoryStructure halconfigDirectoyStructure = |
| 51 | + ctx.getBean(HalconfigDirectoryStructure.class); |
| 52 | + assertThat(halconfigDirectoyStructure.getHalconfigDirectory()) |
| 53 | + .isEqualTo(halconfigDirectory); |
| 54 | + }); |
| 55 | + } |
| 56 | +} |
0 commit comments