Permalink
Browse files

Move hSpec tests for 'lookupNS' into the (tested) docs for 'lookupNS'.

  • Loading branch information...
1 parent 3240c6d commit 4634eab2767e541fa9cd51a7253029be103f1df5 @orlitzky orlitzky committed Sep 12, 2013
Showing with 19 additions and 14 deletions.
  1. +19 −4 Network/DNS/Lookup.hs
  2. +0 −10 test2/LookupSpec.hs
View
@@ -239,10 +239,25 @@ lookupNSImpl lookup_function rlv dom = do
unTag (RD_NS dm) = Right dm
unTag _ = Left UnexpectedRDATA
-{-|
- Resolving 'Domain' by 'NS'. Results taken from the ANSWER section of
- the response.
--}
+-- | Look up all \'NS\' records for the given hostname. The results
+-- are taken from the ANSWER section of the response (as opposed to
+-- AUTHORITY). For details, see e.g.
+-- <http://www.zytrax.com/books/dns/ch15/>.
+--
+-- There will typically be more than one name server for a
+-- domain. It is therefore extra important to sort the results if
+-- you prefer them to be at all deterministic.
+--
+-- Examples:
+--
+-- >>> import Data.List (sort)
+-- >>> let hostname = Data.ByteString.Char8.pack "mew.org"
+-- >>>
+-- >>> rs <- makeResolvSeed defaultResolvConf
+-- >>> ns <- withResolver rs $ \resolver -> lookupNS resolver hostname
+-- >>> fmap sort ns
+-- Right ["ns1.mew.org.","ns2.mew.org."]
+--
lookupNS :: Resolver -> Domain -> IO (Either DNSError [Domain])
lookupNS = lookupNSImpl DNS.lookup
View
@@ -19,16 +19,6 @@ spec = do
`shouldReturn`
Right []
- describe "lookupNS" $ do
- it "gets NS" $ do
- rs <- makeResolvSeed defaultResolvConf
- withResolver rs $ \resolver -> do
- actual <- DNS.lookupNS resolver "mew.org"
- let expected = Right ["ns1.mew.org.", "ns2.mew.org."]
- -- The order of NS records is variable, so we sort the
- -- result.
- sort <$> actual `shouldBe` expected
-
describe "lookupNSAuth" $ do
it "gets NS" $ do
-- We expect the GTLD servers to return the NS in the

0 comments on commit 4634eab

Please sign in to comment.