Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: create recruitment fixture #588

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from

Conversation

dongho108
Copy link
Contributor

@dongho108 dongho108 commented Aug 7, 2022

close #538

테스트시 유의사항

1. TermController, RecruitmentController에서 @LoginUser주석처리 해주셔야합니다.

    @PostMapping
    fun save(
        @RequestBody termData: TermData
//        @LoginUser(administrator = true) user: User
    ): ResponseEntity<ApiResponse<TermResponse>> {
        val response = termService.save(termData)
        return ResponseEntity.created("/api/terms/${response.id}".toUri())
            .body(ApiResponse.success(response))
    }

    @GetMapping("/{termId}")
    fun getById(
        @PathVariable termId: Long
//        @LoginUser(administrator = true) user: User
    ): ResponseEntity<ApiResponse<TermResponse>> {
        val response = termService.getById(termId)
        return ResponseEntity.ok(ApiResponse.success(response))
    }

2. DSL은 아래와 같이 생성할 수 있습니다

Fixture 예시

val term = term {
    name = "100기"
}

val defaultTerm = term()

val recruitment1 = recruitment {
    title = ""
    termId = term.id
    startDateTime = LocalDateTime.now()
    endDateTime = LocalDateTime.now().plusDays(30)
    recruitable = false
    hidden = true
    recruitmentItems = recruitmentItems {
        recruitmentItem()
        recruitmentItem {
            title = "프로그래밍 학습 과정과 현재 자신이 생각하는 역량은?"
            position = 2
            maximumLength = 1500
            description = "우아한테크코스는..."
        }
        recruitmentItem {
            title = "프로그래밍 학습 과정과 현재 자신이 생각하는 역량은?"
            position = 3
            maximumLength = 2000
            description = "우아한테크코스는..."
        }
    }
}


val recruitment2 = recruitment {
    title = ""
    termId = term {
        name = "aa"
    }.id
    startDateTime = LocalDateTime.now()
    endDateTime = LocalDateTime.now().plusDays(30)
    recruitable = false
    hidden = true
    recruitmentItems = recruitmentItems {
        recruitmentItem()
        recruitmentItem {
            title = "프로그래밍 학습 과정과 현재 자신이 생각하는 역량은?"
            position = 2
            maximumLength = 1500
            description = "우아한테크코스는..."
        }
        recruitmentItem {
            title = "프로그래밍 학습 과정과 현재 자신이 생각하는 역량은?"
            position = 3
            maximumLength = 2000
            description = "우아한테크코스는..."
        }
    }
}

val defaultRecruitment = recruitment()

3. RestAssured를 사용하기 때문에 SpringBootTest의 랜덤포트를 RestAssured에 지정해주어야 합니다.

@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
class FixtureTest {

    @LocalServerPort
    private val port = 0

    @BeforeEach
    fun setUp() {
        RestAssured.port = port
    }
}

@woowahan-pjs woowahan-pjs force-pushed the feature/recruitment-fixture branch from f7e09c1 to a3be217 Compare October 26, 2022 10:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants