File: feature.cpp

package info (click to toggle)
restbed 4.0~dfsg1-5
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,388 kB
  • sloc: cpp: 15,273; sh: 37; makefile: 14
file content (50 lines) | stat: -rw-r--r-- 1,211 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
 * Copyright 2013-2016, Corvusoft Ltd, All Rights Reserved.
 */

//System Includes
#include <string>
#include <memory>
#include <stdexcept>

//Project Includes
#include <restbed>

//External Includes
#include <catch.hpp>

//System Namespaces
using std::string;
using std::shared_ptr;
using std::make_shared;
using std::invalid_argument;

//Project Namespaces
using namespace restbed;

//External Namespaces

SCENARIO( "publishing duplicate resources", "[service]" )
{
    GIVEN( "I publish a resource at '/resources/1'" )
    {
        auto resource = make_shared< Resource >( );
        resource->set_path( "/resources/1" );
        
        auto settings = make_shared< Settings >( );
        settings->set_port( 1984 );
        
        Service service;
        service.publish( resource );
        
        WHEN( "I attempt to publish another resource at '/resources/1'" )
        {
            THEN( "I should see an invalid argument error of 'Resource would pollute namespace. Please ensure all published resources have unique paths.'" )
            {
                REQUIRE_THROWS_AS( service.publish( resource ), invalid_argument );
            }
        }
        
        service.stop( );
    }
}