summaryrefslogblamecommitdiffstats
path: root/archives/extend/2013-April/000107.html
blob: dfdb80fa5d3ffde1baaa9da804c945a536c5c179 (plain) (tree)




























































































                                                                                                                                                                                                                                          
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
 <HEAD>
   <TITLE> [99s-extend] populating #http_req for unit testing
   </TITLE>
   <LINK REL="Index" HREF="index.html" >
   <LINK REL="made" HREF="mailto:extend%40lists.ninenines.eu?Subject=Re%3A%20%5B99s-extend%5D%20populating%20%23http_req%20for%20unit%20testing&In-Reply-To=%3CCAKAMJXjXrMs5OR%2BWfHwkmixGAx1UUP4-HyprhTffEjT4yXKBnA%40mail.gmail.com%3E">
   <META NAME="robots" CONTENT="index,nofollow">
   <style type="text/css">
       pre {
           white-space: pre-wrap;       /* css-2.1, curent FF, Opera, Safari */
           }
   </style>
   <META http-equiv="Content-Type" content="text/html; charset=us-ascii">
   <LINK REL="Previous"  HREF="000106.html">
   <LINK REL="Next"  HREF="000108.html">
 </HEAD>
 <BODY BGCOLOR="#ffffff">
   <H1>[99s-extend] populating #http_req for unit testing</H1>
    <B>Eduardo Gurgel</B> 
    <A HREF="mailto:extend%40lists.ninenines.eu?Subject=Re%3A%20%5B99s-extend%5D%20populating%20%23http_req%20for%20unit%20testing&In-Reply-To=%3CCAKAMJXjXrMs5OR%2BWfHwkmixGAx1UUP4-HyprhTffEjT4yXKBnA%40mail.gmail.com%3E"
       TITLE="[99s-extend] populating #http_req for unit testing">edgurgel at gmail.com
       </A><BR>
    <I>Sat Apr 13 13:12:39 CEST 2013</I>
    <P><UL>
        <LI>Previous message: <A HREF="000106.html">[99s-extend] populating #http_req for unit testing
</A></li>
        <LI>Next message: <A HREF="000108.html">[99s-extend] Reading body_qs multiple times
</A></li>
         <LI> <B>Messages sorted by:</B> 
              <a href="date.html#107">[ date ]</a>
              <a href="thread.html#107">[ thread ]</a>
              <a href="subject.html#107">[ subject ]</a>
              <a href="author.html#107">[ author ]</a>
         </LI>
       </UL>
    <HR>  
<!--beginarticle-->
<PRE>On Thu, Apr 11, 2013 at 8:37 PM, Brown, Kevin &lt;<A HREF="https://lists.ninenines.eu/listinfo/extend">Kevin.Brown at turner.com</A>&gt;wrote:

&gt;<i>
</I>&gt;<i> Cowfolk,
</I>&gt;<i>
</I>&gt;<i> I am doing something like this to create an #http_req suitable for unit
</I>&gt;<i> testing my resource callbacks:
</I>&gt;<i>
</I>

I use the library meck(<A HREF="https://github.com/eproxus/meck">https://github.com/eproxus/meck</A>) to test stuff doing
something like this:

some_test() -&gt;
  meck:expect(cowboy_req, binding, 2, {&lt;&lt;&quot;app_key&quot;&gt;&gt;, req} )
  ?assertEqual({ok, req, empty},
                 websocket_handler:websocket_init(transport, req, opts)),
  ?assert(meck:validate(cowboy_req)).

I use simple atoms as input and mock the cowboy_req functions to return
atoms that would represent the correct or the wrong answer.

The real implementation or how cowboy represent stuff is not important
here, just the output pattern like {Binding, Req}.

That's it

-- 

Eduardo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: &lt;<A HREF="http://lists.ninenines.eu/archives/extend/attachments/20130413/f1b70800/attachment.html">http://lists.ninenines.eu/archives/extend/attachments/20130413/f1b70800/attachment.html</A>&gt;
</PRE>

<!--endarticle-->
    <HR>
    <P><UL>
        <!--threads-->
	<LI>Previous message: <A HREF="000106.html">[99s-extend] populating #http_req for unit testing
</A></li>
	<LI>Next message: <A HREF="000108.html">[99s-extend] Reading body_qs multiple times
</A></li>
         <LI> <B>Messages sorted by:</B> 
              <a href="date.html#107">[ date ]</a>
              <a href="thread.html#107">[ thread ]</a>
              <a href="subject.html#107">[ subject ]</a>
              <a href="author.html#107">[ author ]</a>
         </LI>
       </UL>

<hr>
<a href="https://lists.ninenines.eu/listinfo/extend">More information about the Extend
mailing list</a><br>
</body></html>